Monday, January 02, 2012

A Simple C Program

The following is a sample program that creates output:

/* A simple C program */
#include
int main()
{
printf("C is a programming language.\n");
printf("C is very compatible with UNIX/Linux.\n");
}

Output:

C is a programming language.
C is very compatible with UNIX/Linux.


In the preceding program, you see the statement:

#include

This is called a preprocessor directive. The preprocessor processes your program before the compiler translate it into object code. It reads your program, looking for statements that begin with the # symbol. These statements are considered preprocessor directives and cause the preprocessor to modify your source code in some way. For example, the #include directive causes the preprocessor to include another file in your program at the point where the #include directive appears.

No comments:

Post a Comment