Original Post
I'm well aware that this is odd and that this is probably something I SHOULDN'T do in a professional/more serious context. What I want to do is loop through an array without integer's to access specific array positions. This is a two or three dimensional array, consisting of chars. The arrays are all 16 elements in size. Instead of using actual integer values to access positions in these arrays, I instead have two (or three) arrays of booleans, four elements each, representing binary numbers from 0 to 15. Now, doing this in the more rational way, if I wanted to access something in an array, I'd just do something like cout << z[14][2] << endl; or whatever. However, instead, I'm trying to handle this using that binary number array thing.
char array[16] = "abcdefghijklmno";
char *i;
bool byte[4] = {1,0,0,0};
i = array;
i++;
cout << *i << endl;
i = array;
cout << *i << endl;
if(byte[0] == 1) {
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
}
if(byte[1] == 1) {
i++;
i++;
i++;
i++;
}
if(byte[2] == 1) {
i++;
i++;
}
if(byte[3] == 1) {
i++;
}
cout << *i << endl;
This is sort of how I'm doing it right now (While loops would obviously be used in each of the if statements. I'm not really sure why I wrote that like I did, there). Anyway, is there any way to do something similar, for a 2D or 3D array? Or some other way I could iterate through the char array wihout directly accessing the various locations in the array using actual integers?