Reputation: 63
What does this format string do?
fscanf("%30[^$]");
I don't have any idea what it does, and will be so happy for an explanation of it.
Upvotes: 0
Views: 339
Reputation: 13
fscanf reads the data from the stream and stores it based on the parameters. As weathervane stated your code shows max length unless $ is found. You are missing a place to store it. You may find http://www.cplusplus.com/reference/cstdio/fscanf/ useful. It shows how to format fscanf and what different specifiers like % and ^ mean.
Upvotes: 0
Reputation: 34585
30
is the maximum input length of a string, unless '$'
is found.
That is for a string, from a file, but you have no target string or file. Perhaps
char str[31];
FILE *fil = fopen("myfile.txt", "rt");
if(fil == NULL) { /* error */ }
if(fscanf(fil, "%30[^$]", str) != 1) { /* error */ }
Upvotes: 1