#include <stdio.h>
int main()
{
int number; // we make 1 int named number
scanf("%d",&number); // we give to number some number xd
while (number!=0)// we made a loop while if number isn't 0 do that
{
printf("text");// print text
scanf("%d",&number); // and get again a number. So everything works well beside inserting some char instead of int .So what is the problem wont scanf return 0 so we exit the program not just prininting a text all day ?. that's my first question .
}
return 0;
}
第二个问题是如何使程序从键盘上读取数字,直到我输入前一个特殊符号''。是的,我们在做循环的同时对吗?但是,如果我输入除数字以外的所有内容,scanf("%d",&something)
会在什么时候还给我0
?
将其从scanf int更改为char