How to test input is sane

后端 未结 6 1130
一个人的身影
一个人的身影 2020-12-11 11:38

Consider the following simple C program.

//C test

#include

int main()
{
   int a, b, c;

   printf(\"Enter two numbers to add\\n\");
   scan         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-11 12:12

    you can test this one.

    #include 
    
    int main(void)
    {
        int a, b, c;
    
        printf("Enter two numbers to add\n");
        scanf("%d%d",&a,&b);
    
        if(scanf("%d%d",&a,&b) == 2)
        {
            c = a + b;
            printf("Sum of entered numbers = %d\n",c);
        }
        return 0;
    }
    

提交回复
热议问题