C programming interview prep
C programming interview prep
argv is immutable which compels the program to manipulate copies and as they are
strings, conversion functions may be needed like atoi() (ASCII to integer)
Uninitialized data (bss): data with no explicit init are there, init by the kernel
to arith. 0
static int i;
read-only : constants
read-write: global variables
bss : block started by symbol
Heap: dynamic memory allocation happens here, managed by: malloc, calloc,
realloc & free.
shared by all shared libraries and dyn. loaded modules.
Stack: contains the program stack, the top is tracked by the Stack Pointer
(SP), adjusts each time a value (stack frame) is pushed to the stack
A function frame contains at least the return address. Besides, it can contain
arguments and local (automatic) variables as well as some of the machine
registers.
Advanced C features
Constants: alias for a literal value
#define N 50 // preprocessor macros
#define AREA(a) (5.18 * a * a) // preprocessor macros with args
enum days { MON=3, TUE, WED, THU,FRI, SAT, SUN} is equivalent to:
#define MON 3
#define TUE 4
#define WED 5