I am currently watching lecture one in week 1 and have the problem with hello world example professor Malan explained.I do everything by the instructions,save it in Dropbox folder as hello.c.In command prompt i first type cd Dropbox,then ./hello,but instead of the 'hello world' output it says:bash: ./hello: No such file or directory.I checked if Dropbox is synced and it is ok.When i type ls it lists Getting Started.pdf hello.c.So the file is in Dropbox folder.What am I doing wrong?Thank you in advance.
1 Answer
I suppose this is your hello-world program
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
return 0;
}
which is SAVED as hello.c
in your Dropbox folder. Use the following command in terminal to proceed to that folder.
cd ~/Dropbox/
Now, you have the source code of the program with you, but not an executable. You need to make executable by following command.
make hello
This will create an executable filehello
in the same folder(if there are no compilation errors). You didn't make the hello
file and that's why it said No such file or directory
as you tried to run a file that didn't exist .Now you can run this executable with following.
./hello
Best of Luck.