
THE BASIC steps required to create a C or C++ Linux program.
* How to create a C and C++ programs on Linux environment
* Compiling code
* Debugging the result
Program 1. C source file—main.c
#include <stdio.h>
int main(void)
{
printf("\nHello, World\n\n");
return 0;
}
The main function serves a special purpose in C programs:
* The run-time environment calls the main function to begin
program execution.
* The opening curly brace indicates the beginning of the
definition of the main function.
* A function named printf, which was declared in
stdio.h and is supplied from a system library
* The return statement terminates the execution of the main
function and causes it to return the integer value 0, which is
interpreted by the run-time system as an exit code indicating
successful execution.
* The closing curly brace indicates the end of the code for
the main function.
Compiling a single C source file:
The C++ compiler is called g++.
> g++ main.c -o main.c.o
Output:

0 comments:
Post a Comment