![]() |
![]() |
Newbie's Linux Manual |
How Do I Create, Compile And Run a C Program? |
by Laurence Hunter |
[ Home ] [ Contents ] [ Download*] [ Previous ] [ Next ] |
* In Linux enter: unzip nlm.zip |
A 5 Minute Course in C |
For now it's not important that you understand all them cryptic C commands. All that matters is that minutes from now, you'll have learnt how to create a program in C, compile it and run it. Then you can act all smug in front of your mates. ;) - 1 - At the command line, pick a directory to save you program and enter: pico firstprog.c |
Note |
All C source code files must have a .c file extension. - 2 - Enter the following program:
- 3 - Press Ctrl+O to save the file and Ctrl+X to exit. - 4 - Enter: gcc -o myprog firstprog.c ...to create an executable called myprog from your source code (firstprog.c). Here's a detailed discussion of the line above:
- 5 - To run the program, enter: ./myprog |
Note |
The ./ is used to combat trojans, programs used by crackers to circumvent a system's security by "sneaking through the back door". If myprog was not in your current directory, then the relative (relative to current directory) or absolute path (the full path from the root (/) directory) is used. |
Link |
|
[ Home ] [ Contents ] [ Download*] [ Previous ] [ Next ] |
* In Linux enter: unzip nlm.zip |
The Newbie's Linux Manual is reproduced on LinuxMall.com by permission. The Newbie's Linux Manual is written and maintained by Laurence Hunter. You can find much more of Laurence's work at his site: www.Linuxdot.org |
© 1999 Linuxdot.org | Manual's Copyright Terms