0

我使用模拟 Turbo C++ IDE 3.0 进行 C 开发。运行以下程序时出现上述错误:

#include<stdio.h>
#include<conio.h>
main()
{
    int i,j,k;
    char x;
    do
    {
        printf("enter the number i: ");
        scanf("%d",&i );
        printf("enter the number j: ");
        scanf("%d",&j);
        k=i+j;
        printf("Addition of given numbers :%d ",k);
        printf("\n Do you to continue : ");
        scanf("%c",&x);
    } while(x=='y'||x=='Y');    
    getch();
}

它已成功编译,没有错误或警告。在运行时,问题出现在语句之后printf("\n Do you to continue : ");

当我为此输入一个值时,会出现错误。我在开发 C++ 中尝试过,但问题仍然存在。我正在使用 Windows 7 旗舰版。

4

1 回答 1

0

建议

改变

scanf("%c",&x);

scanf(" %c",&x);

于 2013-04-02T08:39:36.337 回答