my code here doesn't scan the character in scanf("%c", &c);, after printf("Enter the type of process); it directly terminate the program. could you please help me I am a beginner at C. what happens in my code
Asked
Active
Viewed 56 times
-2
-
Try adding a `default` to your switch, which prints the un-handled value of `c` you actually received. And, please paste you (minimal) code example here directly, instead of linking a screencap. – Useless Dec 17 '15 at 18:17
-
2This [link](http://stackoverflow.com/questions/13542055/how-to-do-scanf-for-single-char-in-c) might help you!!! – Harish Talanki Dec 17 '15 at 18:18
-
1It is better to put your code in the question that linking a picture. – mpromonet Dec 17 '15 at 18:26
1 Answers
1
Add a default:
label to your switch
statement that prints a message when a character other than +-*/
is entered. Most likely the scanf
operation isn't reading what you think it's reading.
(My guess is that it's reading the newline from your previous input.)

DaoWen
- 32,589
- 6
- 74
- 101