Simple calculator using command line with C++

后端 未结 5 444
遇见更好的自我
遇见更好的自我 2021-01-26 10:57

I\'m writing a project that we do simple calculator from command line. The users input in this format programname firstNumber operator secondNumber. Here what I

5条回答
  •  迷失自我
    2021-01-26 11:44

    The problem is how you transform the string in numbers: you are using atoi which like its name suggests transforms the input in a integer.

    The solution is to simply replace this by atof which will read correctly floating-point numbers.

提交回复
热议问题