I am new to Ubuntu Linux gcc. I have writen c++ programs for windows. I can't get off the ground with gcc. If I use gedit, do I store the hello.c in document? If so, why does:
gcc first.c -o first
not work. It can't find the file.
I am new to Ubuntu Linux gcc. I have writen c++ programs for windows. I can't get off the ground with gcc. If I use gedit, do I store the hello.c in document? If so, why does:
gcc first.c -o first
not work. It can't find the file.
- Is it C++ or C file; for C files you use gcc command, for C++ g++
- Please post exactly the command you are using
- Show us the output of ls -la in the directory where you are compiling; hopefully it is not too crowded.
- Also tell us what is the error message
Last edited by ubix; December 23rd, 2011 at 01:49 AM.
Thread moved to Programming Talk.
Suppose you have the following c program saved in file hello.c:
Assuming you've just saved the file, you would use something like this to compile it:Code:#include <stdio.h> int main(void) { printf("Hello world!\n"); return 0; }
Assuming it compiles correctly, you'd then need to run it with something like this:Code:gcc hello.c -o hello
EDIT/Disclaimer: the code shown is not intended as an example of good programming technique; it is included for illustrative purposes only.Code:./hello
Last edited by lisati; December 23rd, 2011 at 02:01 AM.
Forum DOs and DON'Ts
Please use CODE tags
Including your email address in a post is not recommended
My Blog
you need to issue the command from the directory in which you saved your source file. Or specify the absolute path to the source.
Edit: D'oh, someone covered that above
clear && echo paste url and press enter; read paste; (youtube-dl $paste) | zenity --progress --title="☠" --text "Downloading, please wait" --auto-close --pulsate && ans=$(zenity --file-selection); gnome-terminal -x mplayer "$ans"
Enter the following in terminal:
Code:mkdir my-c-test cd my-c-test echo "int main(void){}" > test1.c gcc test1.c -o test1 ls -l
You should now see something like:
Code:-rwxr-xr-x 1 you you 8335 2011-12-22 20:10 test1 -rw-r--r-- 1 you you 17 2011-12-22 20:10 test1.c
Thank you!
cd Documents
makes a difference. Now I have compiled several 'hello world' programs.
This question is just about solved.
Should this question start a new thread?
if i change "hello world" to "hello world\n", It does not like the escape sequence?
Bookmarks