Interesting C Question
Take a look at the following code:
Code:
char a[10] = "abcdefghi"; It must be something to do with the way the string is represented in the memory by the C compiler, but what is it? I would have thought that the offset is multiplied by the size of char, in which case they should give different outputs :/ |
Re: Interesting C Question
Yes this is quite cool...
In C, Code:
x[\i] Code:
*(x + i) Code:
*(i + x) Code:
i[x] Quote:
greets, nukkel |
The size of the type actually shouldn't matter in this case. Pointers in C are always the same size, regardless of the datatype they are pointing too.
|
All times are GMT -5. The time now is 09:39 PM. |