I've got a problem- I assign my pointer variable to something in a called function, but when trying to access the updated pointer in the calling functions, it doesnt show as updated, and results in a seg fault. Help!
"Bottommost function":
void compareStrings(char* firstFrag, char* secondFrag, int* longestCommonLength, char* suffix, char* prefix, int* relative_pos) {
suffix = firstFrag;
prefix = secondFrag;
}
It is called from this function (the printf triggers the fault)
int findBestOverlap(char* fragmentArray[], int fragmentCount, int* longestCommonLength, char* suffix, char* prefix, int* relative_pos) {
compareStrings(fragmentArray[firstFrag], fragmentArray[secondFrag], longestCommonLength, suffix, prefix, relative_pos);
printf("LCL: %i || PREFIX: %s || SUFFIX: %s", *longestCommonLength, prefix, suffix);
}
The variables prefix and suffix are in turned created in a higher calling function, processStrings.
void processStrings(char* fragmentArray[], int fragmentCount) {
int longestCommonLength = 0;
char* suffix;
char* prefix;
int relative_pos; // Where the first letter of suffix is, vis-a-vis prefix
if ((findBestOverlap(fragmentArray, fragmentCount, &longestCommonLength, suffix, prefix, &relative_pos)) != 0) {
}
}
Help!