🔸Basic Structure
hello world in C
Detect the Version of C in use
Comments
Taking command line arguments
NULL character and NULL
null character \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.we can add a \0 to the end of a string, this will create two strings but only the first one will be printed.
NULL
NULL is a symbol that represents a memory address that doesn't reference anything
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 : 1. create a header file pointing to a source file: create other.h → header file\
this is pointing to a source file with the name other.c (same as header.c) which contains the source instructions for this header. when we include this header in the main.c source file it refers to the header and the header refers to the other.c source file. 2. 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. we don't need to include anything in this source file 3. include the header in main.c and use the function: create main.c, include header.h and use getme()\
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. then we can use the getme() function defined in other.c source file which is referred to by the other.c header. 4. to compile without an IDE from command line: gcc *.c -o [program name] → compile all .c source files, headers are checked in compile time and are not included in the command use with -c without -o option to keep the object files if you want, we can use object files only to compile the program same as we did with the source files, .o and .c is the same here.
Last updated