i need some help. i need my code to ask the user for his or her name and check with it is shorter then 20 characters. here is what ive done
now it will input a name fine, but anything equal or greater then 20 doesnt work it will print out 20 characters and then the rest of the characters go into the input buffer.Code:do { fprintf(output,"please enter your name:\n");fflush(stdout); fgets(name, 20, input); if (strlen(name)>20) { fprintf(output,"please enter a name less than 20 characters.\n"); } } while (strlen(name)>20);
but also it doesnt print an error message if its over 20. so what is wrong with my loop.