Lacking money ATM so I'm offering $0.25 via paypal to the first person to point out what I did wrong in this code snippet -- I hope this doesn't violate the site rules or insult anybody.
I want to modify an multi-dimensional array in a function. It gets modified while in the function, but when scope returns to the main function the array is unchanged.
The function headers cannot be modified. Thanks for helping me out.
void getAlignment(char*s1, char*s2, char*s3, char*aligned[])
{
/***********************
Code here which assigns
char**tmp to "different" "words"
***********************/
printf("tmp in getAlignment function\n");
printf("%s %s\n", tmp[0], tmp[1]); // prints "different words", as expected
aligned = tmp;
}
int main(void)
{
// skipped some code
char** aligned = (char**)malloc(sizeof(char*)*2);
aligned[0] = "should";
aligned[1] = "change";
printf("%s %s\n", aligned[0], aligned[1]); // prints "should change", as expected
getAlignment(s1, s2, transcript, aligned); // how do i change aligned during this call?
printf("%s %s\n", aligned[0], aligned[1]); // prints "should change"
return 0;
}