If you are a fresher to programming and starting your programming journey with c then you are at a right place to learn to write a basic and your first program in C.

A C program basically consists of the following parts:

 Preprocessor Commands
 Functions
 Variables
 Statements & Expressions
 Comments

Don't worry I'll get you clear understanding. Let's take a look at an example.

#include <stdio.h> 

int main()
{
 /* my first program in C */
 printf("Hello, World! \n");
 
 return 0;
}


Coming to the explaination of the parts above.

#include <stdio.h> or what is an header file ?

The first thing you will notice is the first line of the file, the #include "stdio.h" line. This is very much like the #define the preprocessor , except that instead of a simple substitution, an entire file is read in at this point.
The system will find the file named "stdio.h" and read its entire contents in, replacing this statement.

Obviously then, the file named "stdio.h" must contain valid C source statements that can be compiled as part of a program.
This particular file is composed of several standard #defines to define some of the standard I/O operations.

The file is called a header file and you will find several different header files on the source disks that came with your C compiler.
Each of the header files has a specific purpose and any or all of them can be included in any program.


Fine as now you understood what is an header file in C program let's take a look at the list of inbuilt functions in stdio.h file.

List of inbuilt C functions in stdio.h file:

  1. printf() This function is used to print the character, string, float, integer, octal and hexadecimal values onto the output screen

  2. scanf() This function is used to read a character, string, numeric data from keyboard.

  3. getc() It reads character from file

  4. gets() It reads line from keyboard

  5. getchar() It reads character from keyboard

  6. puts() It writes line to o/p screen

  7. putchar() It writes a character to screen

  8. clearerr() This function clears the error indicators

  9. f open() All file handling functions are defined in stdio.h header file

  10. f close() closes an opened file

  11. getw() reads an integer from file

  12. putw() writes an integer to file

  13. f getc() reads a character from file

  14. putc() writes a character to file

  15. f putc() writes a character to file

  16. f gets() reads string from a file, one line at a time

  17. f puts() writes string to a file

  18. f eof() finds end of file

  19. f getchar reads a character from keyboard

  20. f getc() reads a character from file

  21. f printf() writes formatted data to a file

  22. f scanf() reads formatted data from a file

  23. f getchar reads a character from keyboard

  24. f putchar writes a character from keyboard

  25. f seek() moves file pointer position to given location

  26. SEEK_SET moves file pointer position to the beginning of the file

  27. SEEK_CUR moves file pointer position to given location

  28. SEEK_END moves file pointer position to the end of file.

  29. f tell() gives current position of file pointer

  30. rewind() moves file pointer position to the beginning of the file

  31. putc() writes a character to file

  32. sprint() writes formatted output to string

  33. sscanf() Reads formatted input from a string

  34. remove() deletes a file

  35. fflush() flushes a file


Let's continue more about writing a C program in the very net article on the blog. Stay tuned.