我没有得到我想要的输出

问题描述

#include <stdio.h>
int main() {
    int a,b;
    printf("Enter a number: ");
    scanf("%d",&a);
    printf("Enter another number: ");
    scanf("%d",&b);
    int add = a+b;
    printf("a + b = %d",add);
    return 0;
}

上面是使用操作符的 C 代码

我使用的是 TDM-GCC 4.9.2 64位 编译器。

每当我运行上述程序时,都会得到以下输出

Enter a number:
4

--------------------------------
Process exited after 16.11 seconds with return value 3221225477
Press any key to continue . . .

既不允许我输入其他任何数字,也不显示任何提示

我想要这个输出

Enter a number:
4
Enter another number:
2
a + b = 6

--------------------------------
Process exited after <seconds> seconds with return value 0
Press any key to continue . . .

是编译器问题还是代码错误

解决方法

#include <stdio.h>
int main()
{
    int a,b;

    printf("Enter a number: ");
    scanf("%d",&a);
    printf("Enter another number: ");
    scanf("%d",&b);
    int add = a+b;
    printf("a + b = %d \n",add);
    return 0;
}