Sorry if you have seen this code already, but I have fixed it to almost work perfectly. My issue this time, is that, when A character is entered exceeding 9 characters, my program does not proceed to the appropreate loop.
Example of error:
Code:
Enter words no longer than 9 characters
Enter your 1st word :Bill
Enter your 2nd word :thiswillbemorethannine
Enter your 3rd word :Enter your 4th word :
The character checking loop is as follows;
Code:
for (b=0; b<10; b++)
{
buff[a][b]=fgetc(stdin);
if (buff[a][b]=='\n')
{
buff[a][b]='\0';
break;
}
if (b>=10) /*b is never >= 10, it quits the loop, after 9*/
{
printf("You have entered a word more than 9 characters\n");
while((buff[a][b] = fgetc(stdin))!='\n')
{
a=-1;
goto A;
}
}
}
Maybe I miss understand how loops work, but when 'b' gets increased to 9, the loop runs, then does it get increased to 10, and not follow through with the loop because b<10 is FALSE? Thats my logic of it, so since b = 10 now, it should do my ERROR loop.
I know for a fact the loop above doesn't remove all the information in the buffer, so I don't exactly know how to do that either. (I can't use fflush)
[/code]