Why is this code getting a segmentation fault?
Code:
void char_cat (char *s, char c) {
printf("string to concatenate = %s\n", s);
char *p = s;
int len = strlen(s);
printf("string length = %s\n", len);
while(*p != '\0'){
p++;
}
}
int process_token (char *token, int append) {
char *qString = token;
for (c = token; *c != '\0'; c++){
if(*c == '"'){
if(!append){
append = 1;
}else{
append = 0;
}
}
if(append && *c != '"'){
char_cat(qString, c);
printf("qString now = %s\n", qString);
}
}
printf("append = %d\n", append);
return append;
}
Function call:
Code:
append = process_token (str_token, append);