Slide 4
Slide 4 text
Javier Gonzalez-Sanchez | CSE240 | Spring 2018 | 4
jgs
malloc
#include
#include
int main(){
int x = 5;
int *y = (int*) malloc (sizeof(int));
*y = 7;
printf("value of y: %d \n", *y);
printf("address of y: %p \n", y);
printf("address of y: %p \n", &y);
printf("value of x: %d \n", x);
printf("address of x: %p \n", &x);
free(y);
return 0;
}
7
0x1c
0x1c
y
0x78
5
x
0x74