| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1876 人关注过本帖
标题:请教!
只看楼主 加入收藏
qingxin111
Rank: 2
等 级:论坛游民
帖 子:71
专家分:29
注 册:2008-4-10
结帖率:100%
收藏
 问题点数:0 回复次数:33 
请教!
请问:
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 
2008-06-27 14:40
orzorz
Rank: 1
等 级:新手上路
帖 子:99
专家分:0
注 册:2008-6-25
收藏
得分:0 
You should read your programming books carefully instead of asking this simple question.

不打不相识,不吵也不相识,偶然间竟遇到一直找寻的大牛.
2008-06-27 14:42
qingxin111
Rank: 2
等 级:论坛游民
帖 子:71
专家分:29
注 册:2008-4-10
收藏
得分:0 
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.
2008-06-27 15:20
orzorz
Rank: 1
等 级:新手上路
帖 子:99
专家分:0
注 册:2008-6-25
收藏
得分:0 
[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!

不打不相识,不吵也不相识,偶然间竟遇到一直找寻的大牛.
2008-06-27 15:40
himpo
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:192
专家分:123
注 册:2008-5-16
收藏
得分:0 
一堆鸟语!!(我们不懂英文的都这么说,没别的意思)
这里的getchar()是一个函数,用来输入一个字符。

while(getchar()!='\n')   ;
的意思是说当你输入的不是回车键(\n),就执行while后的语句,
否则while循环结束。
2008-06-27 15:47
qingxin111
Rank: 2
等 级:论坛游民
帖 子:71
专家分:29
注 册:2008-4-10
收藏
得分:0 
Sorry,I konw the "'\n'",please look my answer carefully.
2008-06-27 15:48
liyanhong
Rank: 3Rank: 3
来 自:水星
等 级:禁止访问
威 望:8
帖 子:1867
专家分:0
注 册:2008-5-3
收藏
得分:0 
这是编程中国  不是编程英国

爱上你 是 我的错  可是离 开  又舍不得  听着你为我写的歌     好难过
如果说 我说如果  我们还 能  重新来过   不去计 较 谁对谁错  会怎么做
2008-06-27 15:50
qingxin111
Rank: 2
等 级:论坛游民
帖 子:71
专家分:29
注 册:2008-4-10
收藏
得分:0 
是啊,可是while后面是空格紧接着分号,什么意思???
2008-06-27 15:50
orzorz
Rank: 1
等 级:新手上路
帖 子:99
专家分:0
注 册:2008-6-25
收藏
得分:0 
[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.

不打不相识,不吵也不相识,偶然间竟遇到一直找寻的大牛.
2008-06-27 15:51
orzorz
Rank: 1
等 级:新手上路
帖 子:99
专家分:0
注 册:2008-6-25
收藏
得分:0 
Here are the words you wrote:
"里面的“getchar()”指的是n的编码值还是程序另外要求输入的字符编码值?"
I don't understand what you meant.

不打不相识,不吵也不相识,偶然间竟遇到一直找寻的大牛.
2008-06-27 15:52
快速回复:请教!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012793 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved