Table of Content

Common Commands

# Compile C Program
gcc -O -Wall -W -pedantic -std=c99 -o pun.o pun.c
 
# Create Object Files (-c)
gcc -Wall -Wextra -std=c11 -c modulename.c
 
# Link multiple Object files
gcc filename.o filename2.o -o executable.o
FlagDescription
-WallShow warnings when potential errors are detected
-WProcedures additional error messages beyond -Wall
-pedanticShows warnings when code does not follow the C standard
-ansiDisables features of GCC that aren’t in standard C (Not used with -std)
-std=c89Specify which version of C should be used to check the program
-O2Compiler optimization levels (0 -3)

Expression and Statement

Expression
Something which evaluates to a value
Example: 1+2/x
They always return a value
Expressions can be in statements

Statement
A line of code that does something
Example: GOTO 100
They do not return a value (They are of type void)
Statements cannot be used in expressions

VS Code C Formatting: Clang-Format Style Options
dvdmtw98: Solutions for exercises from “C Programming: A Modern Approach”

Miscellaneous Points

Arrays

Name of arrays in C stores the base address of the array

Library Files

To include the Math library (libm.a) in a program we need to specify the -lm flag
.a (Archive) are static library files and are embedded into our code .so (Shared Object) are dynamic library files and are only referenced by our program