I want to read a text file, character by character, and then do something with the characters and something with the words. This is my implementation:
char c;
char* word="";
fp = fopen("text.txt","rt");
do
{
c = (char)fgetc(fp);
if(c == ' ' || c == '\n' || c == '\0' || c == '\t')
{
//wordfunction(word)
word = ""; //Reset word
}
else
{
strcat(word, &c); //Keeps track of current word
}
//characterfunction(c);
}while(c != EOF);
fclose(fp);
However, when I try to run this my program instantly crashes. Is there a problem with setting word to ""? If so, what should I do instead?