当前位置: 代码迷 >> C语言 >> 请教!
  详细解决方案

请教!

热度:393   发布时间:2008-06-27 14:40:45.0
请教!
请问:
printf("please enter an int:");
while(scanf("%d",&n)!=1){
   while(getchar()!='\n')   ;
   printf("input incorrect.an int again");
}
for(i=0;i<n,++i)……
中的“while(getchar()!='\n')   ;”是什么意思?里面的“getchar()”指的是n的编码值还是程序另外要求输入的字符编码值?
搜索更多相关的解决方案: please  

----------------解决方案--------------------------------------------------------
You should read your programming books carefully instead of asking this simple question.
----------------解决方案--------------------------------------------------------
If I can find the answer in the books,I should not ask for help at here.I am learning this programming by myself,so I must ask others for help when I have answers.
----------------解决方案--------------------------------------------------------
[bo][un]qingxin111[/un] 在 2008-6-27 15:20 的发言:[/bo]

If I can find the answer in the books,I should not ask for help at here.I am learning this programming by myself,so I must ask others for help when I have answers.

Really?
Ho ho~
Please tell me the name of the book,I don't believe there's no explantion of "\n".
You haven't read the book carefully!
----------------解决方案--------------------------------------------------------
一堆鸟语!!(我们不懂英文的都这么说,没别的意思)
这里的getchar()是一个函数,用来输入一个字符。

while(getchar()!='\n')   ;
的意思是说当你输入的不是回车键(\n),就执行while后的语句,
否则while循环结束。
----------------解决方案--------------------------------------------------------
Sorry,I konw the "'\n'",please look my answer carefully.
----------------解决方案--------------------------------------------------------
这是编程中国  不是编程英国
----------------解决方案--------------------------------------------------------
是啊,可是while后面是空格紧接着分号,什么意思???
----------------解决方案--------------------------------------------------------
[bo][un]qingxin111[/un] 在 2008-6-27 15:48 的发言:[/bo]

Sorry,I konw the "'\n'",please look my answer carefully.

Your discription is not clear.
----------------解决方案--------------------------------------------------------
Here are the words you wrote:
"里面的“getchar()”指的是n的编码值还是程序另外要求输入的字符编码值?"
I don't understand what you meant.
----------------解决方案--------------------------------------------------------
  相关解决方案