unsigned char numbers[10];
unsigned char *solution[10];
int main(int argc, char *argv[]) {
for (unsigned char digit = 0; digit < 10; ++digit) {
numbers[digit] = digit;
}
for (unsigned char col = 0; col < 9; ++col) {
*solution[col] = numbers[col + 1];
}
return(0);
}
So I have an array containing possible values, and I have an array of 10 pointers, each of which will be pointing to one of the values. This allows me to easily change a certain value found more than once in the array, by just changing that value. For example, I could change numbers[1] to contain 5, and all pointers pointing to that array index would now be pointing to the value 5.
But now I want to have a pointer pointing to my array of pointers, so that I can use the increment operator ++ to assign the numbers to my array of pointers, and so that I can use that pointer as a parameter for another function. Something like this:
unsigned char numbers[20];
unsigned char *solution[10];
unsigned char ?solutionPtr;
int main(int argc, char *argv[]) {
for (unsigned char digit = 0; digit < 20; ++digit) {
numbers[digit] = digit;
}
?solutionPtr = ?solution;
for (unsigned char col = 0; col < 9; ++col) {
?solutionPtr++ = numbers[col + 1];
}
test(?solutionPtr);
return(0);
}
void test(? solutionPtr) {
for (unsigned char col = 10; col < 19; ++col) {
?solutionPtr++ = numbers[col + 1];
}
}
The question marks shows where I'm having doubt about what to write to make this work. Specifically I'm not sure how many asterisks I will need to use to make it work as intended.


Sign In
Create Account


Back to top









