| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 421 人关注过本帖
标题:找不出错误...望解答...
只看楼主 加入收藏
紫苏子
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-7-5
收藏
 问题点数:0 回复次数:2 
找不出错误...望解答...
#include<stdio.h>
#include<stdlib.h>
#define BUFFERSIZE 1024
int main()
{
unsigned int a,b,sum;
char buffer[BUFFERSIZE];
printf("*************************************\n");
printf("* Welcome to use our counter *\n");
printf("* Input two integers in on line *\n");
printf("* The sum will be printe *\n");
printf("* Input the char '#' to quit *\n");
printf("*************************************\n");
while(fgets(buffer,BUFFERSIZE,stdin)!=NULL)&&(buffer[0]!='#');
{
if(sscanf(buffer,"%d%d",&a,&b)!=2)
{
printf("the input is skipped:%s",buffer);
continue;
}
sum=a+b;
printf("The sum of%dand%dis%d\n",a,b,sum);
}
return 0;
}


望高手指点...运行不了哦...
搜索更多相关主题的帖子: 解答 
2007-07-16 03:14
开心石
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-7-1
收藏
得分:0 
#include<stdio.h>
#include<stdlib.h>
#define BUFFERSIZE 1024
int main()
{
unsigned int a,b,sum;
char buffer[BUFFERSIZE];
printf("*************************************\n");
printf("* Welcome to use our counter *\n");
printf("* Input two integers in on line *\n");
printf("* The sum will be printe *\n");
printf("* Input the char '#' to quit *\n");
printf("*************************************\n");
while(fgets(buffer,BUFFERSIZE,stdin)!=NULL)&&(buffer[0]!='#'); /* while(A),表达试A要用括号 */
{
if(sscanf(buffer,"%d%d",&a,&b)!=2)
{
printf("the input is skipped:%s",buffer);
continue; /* continue 只用与循环语句中,用来退出本次循环,不能用在if句中 */
}
sum=a+b;
printf("The sum of%dand%dis%d\n",a,b,sum);
}
return 0;
}






改成下面样子:
#include<stdio.h>
#include<stdlib.h>
#define BUFFERSIZE 1024
int main()
{
unsigned int a,b,sum;
char buffer[BUFFERSIZE];
printf("*************************************\n");
printf("* Welcome to use our counter *\n");
printf("* Input two integers in on line *\n");
printf("* The sum will be printe *\n");
printf("* Input the char '#' to quit *\n");
printf("*************************************\n");
while((fgets(buffer,BUFFERSIZE,stdin)!=NULL)&&(buffer[0]!='#'));
{
if(sscanf(buffer,"%d%d",&a,&b)!=2)
{
printf("the input is skipped:%s",buffer);
goto loop;
}
sum=a+b;
printf("The sum of%dand%dis%d\n",a,b,sum);
loop:;
}
return 0;
}

[此贴子已经被作者于2007-7-16 9:57:33编辑过]


2007-07-16 09:56
紫苏子
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-7-5
收藏
得分:0 
谢谢~呵呵~~~~

[此贴子已经被作者于2007-7-17 3:30:43编辑过]


我才刚上路.......
2007-07-17 03:22
快速回复:找不出错误...望解答...
数据加载中...
 
   



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

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