Introduction
First Program
Detect the version of C
Comments
Taking command line arguments
NULL "\0"
A special character with the code value 0 is added to the end of each string to mark where it ends.
A string is always terminated by a null character so the length of a string is always one greater than the number of characters in the string that's why "length - 1" is commonly used.
Modular programming
We can put our code in multiple separate files and include the headers in the main file and use another source file to import functions and other instructions.
To do this:
Create a header file pointing to a source file:
Create other.h → header file.
Create the source file for the header:
Create other.c → source file for header.
Here we define the getme() function which was referred to by header and will be used in the main.c source file.
Include the header in main.c and use the function:
Create main.c, include other.h, and use getme() function.
Here we have to include the header file with "double quotations" cause we know its in the same directory so we don't need to look for it in the whole system.
To compile without an IDE from command line & compile all .c source files, headers are checked in compile time and are not included in the command:
gcc *.c -o [program name].
Last updated