fgets and breaking out of while loop
I'm trying to create a file reader for files with the following basic structure:
a INFOA2
b INFOB1
b INFOB2
c INFOC1
c INFOC2
a INFOA2
Here is what I have so far
Code:
while ((fgets(this, 99, fp)) != NULL)
{
if (this[0] == 'a')
{
// DO THIS
while ((fgets(this, 99, fp)) != NULL)
{
if (this[0] == 'b');
else if (this[0] == 'c');
}
}
}
The problem is that in the inner for loop, if "this" is not 'b' or 'c', it should break out of loop and go to look for next 'a'. But with the current if and else if statements, it will of course just skip the next 'a' and go to the next 'b' or 'c'. How can I break out of this loop?
Probably an else statement, but what should it include? I tried an empty else...
Thanks