H
Helmut Tessarek
Came across this old exampe how C (or better said the compiler) doesn't really
understand array indexing...
#include <stdio.h>
#include <stdlib.h>
#define ARSZ 20
main(){
int ar[ARSZ], i;
for(i = 0; i < ARSZ; i++){
ar = i;
i[ar]++;
printf("ar[%d] now = %d\n", i, ar);
}
printf("15[ar] = %d\n", 15[ar]);
exit(EXIT_SUCCESS);
}
After over 2 decades of programming in C, I totally forgot about it.
Just an interesting thing I had to share.
--
Helmut K. C. Tessarek
/*
Thou shalt not follow the NULL pointer for chaos and madness
await thee at its end.
*/
understand array indexing...
#include <stdio.h>
#include <stdlib.h>
#define ARSZ 20
main(){
int ar[ARSZ], i;
for(i = 0; i < ARSZ; i++){
ar = i;
i[ar]++;
printf("ar[%d] now = %d\n", i, ar);
}
printf("15[ar] = %d\n", 15[ar]);
exit(EXIT_SUCCESS);
}
After over 2 decades of programming in C, I totally forgot about it.
Just an interesting thing I had to share.
--
Helmut K. C. Tessarek
/*
Thou shalt not follow the NULL pointer for chaos and madness
await thee at its end.
*/