How much do I actually increment up in memory when I add 1 to a void *, and how much do I increment up in memory when I add 1 to a int *?
Name:
Anonymous2013-04-21 1:42
You can't add to a void*
When you add to an int*, the actual pointer will be incremented by the amount you added multiplied by sizeof(int). This gives it an array-like behaviour.
These two statements are the same: x = *(myPtr + 5);
x = myPtr[5];
Name:
Anonymous2013-04-21 1:44
Actually, turned out I was wrong about void*. Adding 1 to it adds 1 to the pointer itself.
>>3
Thats noet what I mean. I know void *t what I mean. I know void * junk +=1 moves up a byte ( i think) how much does an int * junk+=1 move the pointer up by?
Name:
Anonymous2013-04-21 5:17
sizeof(int) >>3 said this but you must have missed the wording.
>>3,4,7
Arithmetic on void * is not defined by the standard, but some compilers (most notably gcc) allow it anyway. In such exceptional cases a void * will behave the same as a char *.