Why does my program accept one integer too many and input one too few?

前端 未结 3 584
甜味超标
甜味超标 2021-01-25 15:12

I\'d like to understand why the program allows me to input 3 integers when I have defined SIZE as 2. And when it returns the array it only returns two numbers NOT the three I ha

3条回答
  •  攒了一身酷
    2021-01-25 15:54

    Your loops should be

    for (count=0;count

    Array indexing is 0 based in C.

    Since you have a whitespace chatacter (\n) in scanf() call, it waits for you input a non-whitespace character to complete each call. Remove the \n:

       for (count=0;count

提交回复
热议问题