A
Aire
1. If there is a pointer, int* ptr:
int* ptr;
int a = 456;
p=&a;
(*ptr)++;
*ptr++;
++*ptr;
To me, all the above three statements mean "get value of a and increment it
by 1." But the printf() reveals that they are different operation on a.
Could someone tell me why?
2. What differences and effects ++a and a++ have in C programming? Which one
should always used?
3. Code for example:
int* p;
p = malloc(sizeof(int) * 50);
p = p + 10;
free(p);
Will free(p) free all the memory allocated by "malloc" or just part of the
memory malloc'ed, since p is not pointing the beginning of malloc'ed memory
anymore?
Thanks!
int* ptr;
int a = 456;
p=&a;
(*ptr)++;
*ptr++;
++*ptr;
To me, all the above three statements mean "get value of a and increment it
by 1." But the printf() reveals that they are different operation on a.
Could someone tell me why?
2. What differences and effects ++a and a++ have in C programming? Which one
should always used?
3. Code for example:
int* p;
p = malloc(sizeof(int) * 50);
p = p + 10;
free(p);
Will free(p) free all the memory allocated by "malloc" or just part of the
memory malloc'ed, since p is not pointing the beginning of malloc'ed memory
anymore?
Thanks!