Misc Part 1 (C Program Execution and Program Memory Layout)

https://www.youtube.com/watch?v=cJDRShqtTbk

Various Stages Of Program Execution

https://www.youtube.com/watch?v=cJDRShqtTbk

Preprocessor

Figure 1

Compiler

Figure 2

Assembler

Figure 3

Difference between Compiler and Assembler

Pointers and Dynamic variable stack vs heap

Stack

#include <stdio.h>
int total;
int square(int x) {
return x*x
}
int squareOfSum(int x, int y) {
int z = square(x+y)
return z
}
int main()
{
int a = 4
int b = 8
int sum = squareOfSum(a,b)
printf(“%d”,sum)

return 0;
}
Figure 4

Static/Global

Heap

int main()
{
int a = 4
int *p,
p = malloc(size(int))
*p = 10
return 0;
}
int main()
{
int a = 4
int *p,
p = malloc(size(int))
*p = 10
p = malloc(size(int))
*p = 20
return 0;
}
Figure 5
int main()
{
int a = 4
int *p,
p = malloc(size(int))
*p = 10
free(p)
p = malloc(size(int))
*p = 20
return 0;
}

Code (Text) Memory:

int main()
{
printf(“Hello World”);
add(1,1)
return 0;
}
int add(int a , int b ) {
return a + b
}

Swift Value Types

Useful Links

Senior iOS Engineer | HungerStation | Delivery Hero