我想创建一个简单的计算器,但是所要表达的是,我不想两次输入以下信息:
更新代码
#include <stdio.h>
int a, b;
char op;
int main() {
int answer = 0;
printf("Type \"Help\" or start using calculator\n:");
scanf_s("%d %c %d", &a, &op, &b);
switch (op) {
case '+':
answer = a + b;
break;
default:
main();
break;
}
}
我这样做了,但是我的视觉工作室出现了错误
Its something about: **Access violation writing location**
Will update this section once i resolve a small matter
我希望能够做这样的事情;
Type "Help" or start using calculator
: Help
**Show available list of functions**
或
Type "Help" or start using calculator
: 2+5
: 7 (output)
Type "Help" or start using calculator
: 2+5*4/2
: 12 (output)