I am trying to make an input that scans two strings and saves them in specific sizes. If the size is exceeded, the program should print an error statement, if no number is given, and error statement is given. The first input is only one word, while the second is a statement. If the first one does not have input, then it stops running. here is what I have.
char name[51];
char sentance[141];
printf("Enter Username: ");
if (scanf("%50s", username) !=1){
printf("NOT THE INTENDED LENGTH\n");
exit(1);
}
printf("Enter the user's tweet: ");
getchar();
if (fgets(tweet, 141, stdin)==NULL){
printf("Failed to read");
exit(1);
For some reason It wont give the error statements when its longer, and I have no idea how to make an error statement for when it is shorter. Any ideas?