Hi
If I have:
How do I extract an element/string i.e "0000", "0001" etcCode:char bit_pattern[][4][4] = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
Thanks
Hi
If I have:
How do I extract an element/string i.e "0000", "0001" etcCode:char bit_pattern[][4][4] = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
Thanks
By the first two 'coordinates'.How do I extract an element/string
I tried that, when I do:
I get: bit_pattern: 01010110011110001001101010111100110111101111, which is basically some combination of the elements.Code:printf("\n\nbit_pattern: %s\n\n", bit_pattern[1][1]);
Depending on your compiler, you may need to change your intializer...
orCode:char bit_pattern[4][4][] = { "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
Code:char bit_pattern[4][4][] = { {"0000", "0001", "0010", "0011"}, {"0100", "0101", "0110", "0111"}, {"1000", "1001", "1010", "1011"}, {"1100", "1101", "1110", "1111"} };
Shouldn'tbeCode:char bit_pattern[4][4][]orCode:char bit_pattern[][4][5]JimCode:char bit_pattern[4][4][5]
Try something like:
Code:#include <stdio.h> int main(void){ char myarray[][4][5]={{"0000","0001","0010","0011"}, {"0100","0101","0110","0111"}, {"1000","1001","1010","1100"}, {"1101","1110","1111","0000"}}; for(int x=0;x<4;x++) for(int y=0;y<4;y++) printf("%s\n",myarray[x][y]); getchar(); return(0); }
AndrewHunters suggestion worked, thanks.
One more question, how can I assign a pointers value into an array i.e
where printArray is a pointer to a char got from a function. This doesn't seem to work:
But I can print the individual characters of *(printArray + i) and get the right characters just fine. thanksCode:for(i=0; i<10;i++) { empty[i] = *(printArray+i); }
Clearly this is for that hex to binary conversion again, in which case the dimensionality of the array should be reduced by one. Make it char bit_pattern[16][5]
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"