To Create a .c file, right-click on the desktop and select a new document and give the name as print.c. Open the file it may be opened in any text editors type the below instructions
- int main()
- printf(“Execute a sample program\n”);
- printf(“Hello world\n”);
- return 0;
The above program is a hello world sample program.
Now save the file. Open the terminal application and change the directory by using the command as follows:
now compile the program with GCC tool command as follows:
if it doesn’t display anything means the program compiled successfully and generated an executable file in the same directory. so to execute a file, command as follows:
Execute a sample program
Like the above strings displayed on the terminal.
Note: while you compile a .c file without flags means by default compiler will generate the executable file with the a.out. If you want to get with a different name means you have to pass -c flag to the compiling instruction.
gcc print.c -c print