hello,
i have started to learn C. The code below is from Lesson 6 here on this site tutorial. It compiles and runs OK.
After the code has been run is the pointer still pointing to the integer and pc memory not freed?
Using Windows XP and Bloodshed Dev++ compiler.
Thanks,
aivars
Code:
#include <stdio.h>
int main()
{
int x; /* A normal integer*/
int *p; /* A pointer to an integer ("*p" is an integer, so p
must be a pointer to an integer) */
p = &x; /* Read it, "assign the address of x to p" */
scanf( "%d", &x ); /* Put a value in x, we could also use p here */
printf( "%d\n", *p ); /* Note the use of the * to get the value */
getchar();
}