B
bml
Q1:
int i = 0;
char *p = i;
Is this assign 0 to p or assigning the value pointed by p to 0?
Is this a problem since p has not been initialized, it could point to any
place in memory and assign a value to it could cause access violation?
Q2:
Why might explicit casts on malloc's return value, as in
int *ip = (int *)malloc(10 * sizeof(int));
be a bad style?
Q3:
Why casting in C is so "dangerous" sometimes?
Thanks a lot!
int i = 0;
char *p = i;
Is this assign 0 to p or assigning the value pointed by p to 0?
Is this a problem since p has not been initialized, it could point to any
place in memory and assign a value to it could cause access violation?
Q2:
Why might explicit casts on malloc's return value, as in
int *ip = (int *)malloc(10 * sizeof(int));
be a bad style?
Q3:
Why casting in C is so "dangerous" sometimes?
Thanks a lot!