Brand new to C here. The program is supposed to read in a file of fragments on a single line, separated by a "#" before and after them. For example #fragment1##fragment2##fragment3#
The two errors I want to check for are that a fragment is not over 1000 characters, and that the file follows the correct format of "#" on either side of fragments. I don't really get how fscanf syntax works but I think the following would check for the errors:
char buffer[MAX_FRAG_LEN+1];
if (fscanf(fp, "#%1000[^#]#", buffer) == 1) {
return strdup(buffer);
} else {
fprintf(stderr, "Error! Incorrect format.\n");
}
However, I want to separate the errors so I can specifically deliver a message of which of the two it was. How can I make the checks individually? Much appreciated!