J
Janice
My working system requires the starting address of a piece of data (an int,
a long, etc.) must be a multiple of 4. If the requirement is not met, a
segmentation fault occurs.
My question is the following.
For example,
int a = buf[x]; //The buf is an int array
How come the x must be a multiple of 4?
If the x cannot be a multiple of 4, will the following statement also cause
segmentation fault?
buf[3]=10;
Then, why the following is a solution?
x=3;
memcpy(a, buf+x, sizeof(int));
Thanx
a long, etc.) must be a multiple of 4. If the requirement is not met, a
segmentation fault occurs.
My question is the following.
For example,
int a = buf[x]; //The buf is an int array
How come the x must be a multiple of 4?
If the x cannot be a multiple of 4, will the following statement also cause
segmentation fault?
buf[3]=10;
Then, why the following is a solution?
x=3;
memcpy(a, buf+x, sizeof(int));
Thanx