【发布时间】:2012-10-13 06:02:57
【问题描述】:
我正在尝试制作一个简单的 c 计算器,因为我是一个新手,并且认为这将是一个好主意。这是我的代码:
#include <stdio.h>
main()
{
char b;
int a,c,d;
printf("Please enter your first number: ");
scanf("%d",&a);
printf("Please enter your second number: ");
scanf("%d",%c);
printf("Enter your operation");
scanf("%c",&b);
if (b == 'a')
{
d = a + c;
printf("The answer is: %d",d);
}
}
当我编译代码时,这是我得到的错误/警告:
D:...|4|warning: return type defaults to 'int'|
D:...||In function 'main':|
D:...|10|error: expected expression before '%' token|
有人可以帮忙吗?
【问题讨论】:
-
将
main()声明为int main(void)并从中返回0。
标签: c scanf calculator