PDA

View Full Version : hello world wont work


jswan
February 19th, 2006, 08:51 PM
#include <stdlib.h>
#include <stdio.h>

int main() {
printf("helllo\n");
return 0;
}


gcc test.c -o test
After i compile this and run the output it never prints to the screen
What could cause this? I've been using my schools linux boxes for programming in the past and I am just starting to get my own up and running.

thanks!

skirkpatrick
February 19th, 2006, 10:01 PM
Are you running it from a terminal window? Double-clicking it in Nautilus will not cause a terminal window to open and show you the results.

darth_vector
February 19th, 2006, 10:31 PM
you do know that there is a program called test, dont you? try running./test

Jessehk
February 19th, 2006, 10:38 PM
First step: open text editor.

type in the following:



#include <stdio.h>

int main()
{
printf("Hello, world!\n");

return 0;
}



Save the file as hello.c

enter the following in a terminal window:


gcc hello.c -o hello


While in the terminal window, type ./hello to run.

jswan
February 19th, 2006, 10:51 PM
thanks darth_vector, it worked

definately a rookie mistake

darth_vector
February 19th, 2006, 11:11 PM
no worries mate. i've done that too :D

Plank117
February 20th, 2006, 05:21 PM
May the favor of the compiler be with you, o' seeker of wisdom.

scourge
February 20th, 2006, 05:43 PM
Yet another programmer reinventing the wheel.
If people would just learn to use apt-get they wouldn't have to write their own hello world app, and they could instead spend that time optimizing Linux kernel.

sudo apt-get install hello
hello

:D

HwyXingFrog
March 25th, 2006, 10:57 AM
First step: open text editor.

type in the following:



#include <stdio.h>

int main()
{
printf("Hello, world!\n");

return 0;
}



Save the file as hello.c

enter the following in a terminal window:


gcc hello.c -o hello


While in the terminal window, type ./hello to run.
It is so simple it was difficult to find something this basic on the forums.

For some reason i was trying to run it without ./ and the first time I tried it with the ./ it said the file was not found. So i deleted everything and started over, then it worked for some reason. Sounds like something that would happen on Windows, I know.

Thanks, I was starting to think I wouldn't be able to to it.

sharperguy
March 25th, 2006, 11:38 AM
Yet another programmer reinventing the wheel.
If people would just learn to use apt-get they wouldn't have to write their own hello world app, and they could instead spend that time optimizing Linux kernel.



:D

d8=

Thanks, I was just looking for a useless program such as that.

Wouldnt this make more sense though:

#include <stdio.h>

int main()
{
printf("Please to not attempt to talk to the command line\n");

return 0;
}


Then stick it in /usr/bin

Drakx
March 25th, 2006, 12:10 PM
lmao