PDA

View Full Version : running simple C programs



JPotter
January 15th, 2008, 06:22 AM
I appologize for the extreme simplicity of this question, but I find any similar posts. I switched over to Ubuntu Linux over the Winter, and I am commited to use it as much as I can. I am taking an advanced C programming course this quarter, and I thought gcc would be great! I only have one, rather pressing, problem. I can't figure out how to get the output from my programs.

after compilation using


gcc -Wall -o hello_world hello_world.c


#include <stdio.h>

int main()
{
printf("%s","Hello World!");
return 0;
}

I tried to run the program by typing in the output file's name, but I get:


bash: hello_world: command not found

so . . . if you don't want to read the top, the question is: How do I run this program, and see the output?

CptPicard
January 15th, 2008, 06:32 AM
The current directory is not in the "path" variable for security reasons. So you need to explicitly give the whole path to the executable, by using "." for "current directory".



./your_binary

JPotter
January 15th, 2008, 06:33 AM
Thank you!

worked like a charm!