How to test input is sane

后端 未结 6 1134
一个人的身影
一个人的身影 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:23

    A simple way would be,

    int a=0, b=0, c=0;
    

    initialise them to 0

    Additionally, the check suggested by Midhun is good to check if there are two inputs.

提交回复
热议问题