LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: mantou

GCC 提示没有stdio.h文件。

[复制链接]
发表于 2005-8-26 23:22:51 | 显示全部楼层
K&R 的不错
回复 支持 反对

使用道具 举报

发表于 2005-8-27 00:45:55 | 显示全部楼层
关于“行号”的问题
在gcc后面加-Wall
gcc -Wall
就会提示行号了。

函数clrsc,gotoxy是非标准函数,估计除了TC,没有其他的C有这些函数的实现了。非用不可的话可以考虑用其他库函数代替。
函数getch,还有一个类似的函数getche,可能是包含在头文件conio.h中的。你自己查一下吧。
回复 支持 反对

使用道具 举报

发表于 2005-8-27 09:56:38 | 显示全部楼层
终端下的图形界面编程,可以看看ncurses
画图的话参考一下svgalib
标准c里面没有图形库,这个和硬件平台,还有操作系统,编译器都是相关的,可移植性很差的
回复 支持 反对

使用道具 举报

发表于 2005-8-27 15:59:45 | 显示全部楼层
Post by mantou
#include <stdio.h>
      
      3
      4 void lgc(void);
      5 char answer;
      6
      7 int main()
      8 {
      9     char a;
     10     clrscr();
     11     gotoxy(12,3);
     12     puts("Welcomto to Linux");
     13     gotoxy(15,13);
     14     printf("<CR>--Continue");
     15
     16     while(1)
     17     {
     18        a=getch();
     19        if(a==27)
     20           break;
     21        if(a==13)
     22          {
     23            lgc();
     24            if(answer=='y' || answer=='Y')
     25             {
     26               gotoxy(23,14);
     27               puts("lease write to the Linux");
     28               getch();
     29               break;
     30             }
     31          }
     32     }
     33   return(0);
     34 }
     35
     36 void lgc(void)
     37 {
     38     clrscr();
     39     gotoxy(12,8);
     40     printf("The Excellent Selection!");
     41     gotoxy(21,12);
     42     printf("Do you have any question?(Y/N)");
     43     answer=getch();
     44 }


gcc -o 1 1.c
/tmp/ccTmsCEl.o: In function `main':
1.c.text+0x1d): undefined reference to `clrscr'
1.c.text+0x29): undefined reference to `gotoxy'
1.c.text+0x48): undefined reference to `gotoxy'
1.c.text+0x62): undefined reference to `getch'
1.c.text+0x94): undefined reference to `gotoxy'
1.c.text+0xac): undefined reference to `getch'
/tmp/ccTmsCEl.o: In function `lgc':
1.c.text+0xbe): undefined reference to `clrscr'
1.c.text+0xca): undefined reference to `gotoxy'
1.c.text+0xe9): undefined reference to `gotoxy'
1.c.text+0x101): undefined reference to `getch'
collect2: ld returned 1 exit status


怎么提示的错误,没有显示行号?? 怎么是十六进制的?/    clrscr,gotoxy 需要那些头文件,现在有点忘了

#include <system.h>  也找不到这个头文件,我要把常用的头文件都装好,要怎么装呀??


Functions like 'gotoxy' and 'clrscr', etc. are provided in TC by Borland, which are not stantard functions. I had found them in Dev C++ for Windows, which is a IDE based on GCC and some extended libs supplied by Dev C++ itself for some programers take TC as the only C language version in the world. In Linux, NO such functions available in any libs known by me by now.

Programming in Windows and in Linux is not quite the same. The C language in both OS has no different while the libs and interfaces offered by OS are far from the same. So, taking some time to learn the system itself is a useful and worthwhile step, I think.
回复 支持 反对

使用道具 举报

发表于 2005-8-28 23:47:48 | 显示全部楼层
Post by mantou
#include <stdio.h>
      
怎么提示的错误,没有显示行号?? 怎么是十六进制的?/    clrscr,gotoxy 需要那些头文件,现在有点忘了

#include <system.h>  也找不到这个头文件,我要把常用的头文件都装好,要怎么装呀??


呵呵,这些都是链接阶段发生的错误,又不是编译错误,怎么可能显示行号呢?
再说,你用的库是Turbo C里面的,不是标准的C库,在Linux里面当然不会包含。
回复 支持 反对

使用道具 举报

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

本版积分规则

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