The question that was given to me is to prompt the user to enter a number followed by an operator and lastly a number,
eg:
User Input: 5 + 5
Program Output: 5 + 5 is 10
I tried using the statements below
scanf("%lf",&number1); //number
scanf("%s",&operate); //operator
scanf("%lf",&number2); //number
and it works when I types 5 + 5, it fails when I entered 5+5 or
5+ 5 or even 5 +5. How do I recitify this problem?
Thanks for your help in advance.



LinkBack URL
About LinkBacks



):
This works: