So you are trying to set up BOSS for some C programming? Heres a basic how-to.
The first thing you’ll need is a compiler, gcc the GNU C Compiler comes installed by default in BOSS. Next you’ll need an editor, many editors(vi, nano, gedit to name a few) come installed by default in BOSS Linux. You can also use IDEs like Anjuta, Eclipse, Netbeans etc.
Lets get this started: we will be using Gedit, get to a terminal window(Applications>Accessories>Terminal) once on the terminal window type:
or any other filename of your choice in place of firstfile, be sure to use the .c extension. Otherwise GCC will not be able to recognize it as a C source file. Press the Enter key and type the following code in the Gedit window:
I am sure you have seen something like this before 🙂 its just a basic program to get you feet wet, Most students from India start off C/C++ programming with the Turbo C++ Version 3.0 compiler and are in the habit of using getch(); at the end of the code to basically make the execution wait for the user to press a key before completion. Well, conio.h is not a part of the C Language and it limited to old MS-DOS C Compilers, so I used getchar() in its place, it does pretty much the same thing in this program.
Now save the file and close gedit to get back to the terminal window. We will now compile firtsfile.c. Type:
If all goes well the prompt will reappear on the next line without any message, otherwise you’ll see an error message.
Now we will execute the file, the default name for the executable is a.out, to execute it type:
and press Enter on the terminal, you will see:
with the blinking cursor to the right of the d Press enter to return to the prompt.
On windows with Turbo C++ you have firstfile.exe as the executable generated, a.out is the default name for the executable file created by GCC. To use a name of your choice use the -o argument with gcc:
gcc firstfile.c -o firstfile
this will generate an executable by the name firstfile.
Happy Coding 🙂