-2

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

  • 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
  • 2
    This [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
  • 1
    It is better to put your code in the question that linking a picture. – mpromonet Dec 17 '15 at 18:26

1 Answers1

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