I am doing “cat words | sign” (words is the text file and sign is the c program). However this seems to generate a infinite loop. Any idea how to solve this?
And what is the meaning of
sign < words | @sort > out
Below is the code for the c program.
int main(){
char words[80];
scanf("%s", words);
printf(words);
string_sort(words);
printf(" ");
printf(words);
printf("\n");
while ( words != ""){
scanf("%s", words);
printf("%s", words);
string_sort(words);
printf("%s", " ");
printf("%s", words);
printf("\n");
}
}
When the program reaches EOF,
scanf()leaveswordsunchanged, wich causeswords != ""always be true.Instead of testing
words, you should test forfeof(stdin).