🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

pointer trouble

Started by
9 comments, last by fenrir 24 years, 6 months ago
Don''t know if it helps... but maybe this is what you''re looking for.

int b[2][2] = { 0, 0, 0, 0 };
int *pb = b[0];

Now I could do:

pb[0] = 1;
pb[1] = 2;
pb[2] = 3;
pb[3] = 4;

printf("b[0][0] = %i\nb[0][1] = %i\nb[1][0] = %i\nb[1][1] = %i", b[0][0], b[0][1], b[1][0], b[1][1]);

The output would be:

b[0][0] = 1
b[0][1] = 2
b[1][0] = 3
b[1][1] = 4

Is that what you''re trying to do? You could multiply the array indices to get the index to use with the pointer quite easily.

Good luck

Starfall

This topic is closed to new replies.

Advertisement