I'm trying to create functions out of existing code in order to make it cleaner, and I'm having some problems:
It used to be:
int foo(char * s, char * t, char ** out) {
int val = strcmp(s, t);
if (val == 0) {
*out = strdup(s);
return 1;
} else {
*out = strdup(t);
return 5;
}
return 0;
}
Now I have:
int foo(char * s, char * t, char ** out) {
someFunction(s, t, out);
printf("%s", *out);
return 0;
}
int someFunction(char *s, char * t, char **out) {
int val = strcmp(s, t);
if (val == 0) {
*out = strdup(s);
return 1;
} else {
*out = strdup(t);
return 5;
}
return 0;
}
And I'm getting segmentation faults when I try to do the printf. Should someFunction be expecting a *out? I guess I'm still confused.