For pset1 I want to reject an empty user input, so that when the user presses 'enter', either the Mario code runs or it gives the user an error message.
Pseudo code:
- printf ('message to input 1-23');
scansf ('%i', &height);
if (input <= 23 && input > 0)
{ ... a do/while (with 2 nested for) runs mario if input is 1-23. }
- else
{ printf ("prints error message if input isn't 1-23");}
This rejects numbers outside the range and all characters, but not empty spaces. I reckon there's an elegant solution to this (can fgets work? How?), but advice would be helpful at this point.
Question: How do I reject an empty user input?