#include<stdio.h>
main()
{
FILE *fp;
char ch;
if((fp=fopen("d:\\jrzh\\example\\c1.txt","rt"))==NULL)
{
printf("\nCannot open file strike any key exit!");
getch();
exit(1);
}
ch=fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
}
问题1:警告:隐式声明与内建函数‘exit’不兼容
解决:头文件中加入#include<stdlib.h>
问题2:hello.c:(.text+0x38): undefined reference to `getch'
解决:curses在有的发行版上面叫curses,有的叫ncurses。你编译的时候要加入 -lcurses