LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1897|回复: 6

我用gcc编译程序,提示一错误,看不明白!

[复制链接]
发表于 2007-3-19 17:47:21 | 显示全部楼层 |阅读模式
各位兄弟,我是学程序设计的,因为win下编译自己实在是觉得麻烦,所以来到linux下。
使用gcc进行编译。 所以我的问题可能比较菜,也请大家在回答时,可以详细些,在下
感激不尽!!
以下是问题描述:
我写的一个猜数游戏
#include<stdio.h>
int main()
{
int number=5;
int cai;
printf("请输入一个数字进行比较:");
scanf("%d",&cai);
do
{
if(cai>number)
printf("ssss");
else
{
if (cai < number)
printf("zhegexiao");

}while (cai!=number);

在编译时提示的错误:
sun.c:17: error: stray ‘\357’ in program
sun.c:17: error: stray ‘\275’ in program
sun.c:17: error: stray ‘\235’ in program
sun.c:19: error: expected ‘while’ at end of input

在百度是找,有的说是可能是加入了一些汉子符号。可是我找来找去,也没发现有。

再说下我的机器的情况:
Linux linux-xiaozong 2.6.16.21-0.25-xenpae #1 SMP Tue Sep 19 07:26:15 UTC 2006 i686 i686 i386 GNU/Linux
使用的是suse10.1 版本的。

谢谢大家了!!
发表于 2007-3-19 18:08:21 | 显示全部楼层
拜托,我一眼就看出来了

  1. #include<stdio.h>
  2. int main()
  3. {
  4. int number=5;
  5. int cai;
  6. printf("请输入一个数字进行比较:");
  7. scanf("%d",&cai);
  8. do
  9. {
  10. if(cai>number)
  11. printf("ssss");
  12. else
  13. {
  14. if (cai < number)
  15. printf("zhegexiao");
  16. }<-----汉字符号就是这个
  17. }while (cai!=number);

复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-3-19 18:25:44 | 显示全部楼层
嘿嘿,问题已经解决了,你找的也很对。
可是还有几个呢??

还有,多谢兄弟的关注了。
回复 支持 反对

使用道具 举报

发表于 2007-3-19 21:32:10 | 显示全部楼层
sun.c:17: error: stray ‘\357’ in program
sun.c:17: error: stray ‘\275’ in program
sun.c:17: error: stray ‘\235’ in program
不是都在第十七行吗,一个中文字符有好几个byte呢。
回复 支持 反对

使用道具 举报

发表于 2007-3-21 17:52:26 | 显示全部楼层
中文的空格!!
回复 支持 反对

使用道具 举报

发表于 2007-3-29 20:40:42 | 显示全部楼层
怎么捕·用户“入的异常,Ô如“入¹向键,Þ车后有异常,÷测Õ一下
回复 支持 反对

使用道具 举报

发表于 2007-3-30 11:41:08 | 显示全部楼层
你最后还少一个}
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表