I want to count the number of accounts in a text file, but for some reason I keep getting the wrong number of accounts.
The accounts are structured like this in the text file:
accountName
accountPassword
accountNickname
accountId(this is just the position of the account in the file)
accountType
if the account type is 1 (as opposed to 2) there is also:
0
0
0
0
0
So an example of a text file with some accounts in it might look like:
bob1
password1
bobby
1
1
0
0
0
0
0
tony1
password1
tony
2
2
mary1
password1
mary
3
2
dave1
password1
dave
4
1
0
0
0
0
0
Here is my code for finding out how many accounts there are in the text file:
userId = 0;
while(!feof(fp))
{
    fgets(dump,100, fp);        
    fgets(dump,100, fp);
    fgets(dump,100, fp);
    fgets(dump,100, fp);                  
    fscanf(fp,"%i",&tmpAccType);              // fifth line from start of account is always account type
    if (tmpAccType == 1)                       // if the user type is an registered user we must skip more variable lines
    {
        fgets(dump,100, fp);
        fgets(dump,100, fp);
        fgets(dump,100, fp);
        fgets(dump,100, fp);
        fgets(dump,100, fp);
    }
   userId++;   //add one to the account position
}
fclose(fp);
For some reason after adding 3-5 accounts the program will start to return the wrong amount of accounts. If someone could help me out it would be greatly appreciated :D
 
     
     
    