LinuxSir.cn,穿越时空的Linuxsir!

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

TC编译成功,但gcc编译不了.

[复制链接]
发表于 2002-10-28 10:47:17 | 显示全部楼层 |阅读模式
这是一个链栈的演示程序.
选择1,为入栈操作.选择2,为出栈.
选择3,为清空操作,选择4,为退出.
TC能够正确的编译出来,但是GCC就报错,而且报的错误莫名其妙.如下:
z2.c:55: stray '\32' in program
z2.c:55:2: warning: no newline at end of file
我这个程序只有54行,哪里出来的55行啊?
郁闷+茫然.





1 #include<stdio.h>
      2
      3 void clear(char array[6])
      4 {int i;
      5  for (i=0;i<6;i++)
      6    array='-';
      7 }
      8
      9 void insert(char array[6])
     10 {int i;
     11  char x;
     12   flushall();
     13   printf("Enter a char which you will insert: ");
     14   x=getchar();
     15   for (i=0;i<6;i++)
     16     if (array=='-') break;
     17   array=x;
     18 }
     19 void delete(char array[6])
     20 {int i;
     21  for (i=0;i<6;i++)
     22    if (array=='-') break;
     23  array[i-1]='-';
24 }
     25
     26 main()
     27 {int i,x;
     28  char a[6]={'-','-','-','-','-','-'};
     29
     30  loop:flushall();
     31  printf("           Viaduct  Of  Program            \n");
     32  printf("===========================================\n");
     33  printf("| 1.Input viaduct    | 2. Output viaduct  |\n");
     34  printf(" | 3.Clear empty      | 4. Out program     |\n");
     35  printf("===========================================\n");
     36  printf("\n");
     37  printf("Enter your choose (1 to 4): ");
     38  scanf("%d",&x);
     39  while(x<1 || x>4)
     40    {flushall();
     41     printf("Data error ! Input  1 to 4 again: ");
     42     scanf("%d",&x);
     43    }
     44  while(x!=4)     45    {switch (x)
     46      {case 1:insert(a);break;
     47       case 2:delete(a);break;
     48       case 3:clear(a);break;};
     49       for (i=0;i<6;i++)
     50     printf("%5c",a);
     51     printf("\n");printf("\n");printf("\n");
     52     goto loop;};
     53  printf("The program over, Thanks for you used.\n");
     54 }
发表于 2002-10-28 14:25:01 | 显示全部楼层
发表于 2002-10-28 16:03:31 | 显示全部楼层

多打一个回车试试

main()这种形式不符和ANSI C的标准
发表于 2002-10-28 16:05:12 | 显示全部楼层

GOTO这种形式最好禁用

搞的不好连错都找不到
 楼主| 发表于 2002-10-28 16:33:35 | 显示全部楼层

Re: GOTO这种形式最好禁用

最初由 lensson 发布
搞的不好连错都找不到


老大,我也是没有办法啊,我知道goto不太好,但是我C还刚刚入门,暂时想不出用while处理.
希望兄弟给予我指点.
 楼主| 发表于 2002-10-28 16:48:34 | 显示全部楼层
最初由 Linuxfish 发布
试试:
http://www.linuxsir.cn/forum.php?mod=viewthread&tid=6989

明白了.这个问题已经解决.
/tmp/ccZE8Ive.o: In function `insert':
/tmp/ccZE8Ive.o(.text+0x2f): undefined reference to `flushall'
/tmp/ccZE8Ive.o: In function `main':
/tmp/ccZE8Ive.o(.text+0xdd): undefined reference to `flushall'
/tmp/ccZE8Ive.o(.text+0x174): undefined reference to `flushall'
collect2: ld returned 1 exit status
在GCC的函数库中,清键盘缓冲函数flushall在<stdio.h>的头函数中,但GCC的flushall函数好像在<stdio.h>中找不到啊.
请兄弟们指点.
发表于 2002-10-31 18:16:04 | 显示全部楼层
得调用 term io 的东西, 没有 flushall 这个函数. 它不是标准 C 函数
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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