char *extractSubstring(char *str)
{
char temp[256];
char *subString; // the "result"
printf("%s\n", str); //prints #include "hello.txt"
strcpy(temp, str); //copies string before tokenizing
subString = strtok(str,"\""); // find the first double quote
subString = strtok(NULL,"\""); // find the second double quote
printf("%s\n", subString); //prints hello.txt
strcpy(str, temp); //<---- the problem
printf("%s", subString); //prints hello.txt"
return subString;
}
After I strcpy, why does it add a quotation? When I comment out the 2nd strcpy line, the program works. The printfs will be deleted out of my program. I was just using it to show what was happening with my program.
Can someone please explain to me what is going on? Thank you.