[求助] gcc编译过程中对getch不支持,具体情况如下:
#include "stdio.h"mian()
{
int i=1,j;
char con_key='\x20';
float score[5],ratio[4]={0.1,0.2,0.2,0.5};
while (con_key=='\x20')
{
clrscr();
printf("输入第%2d秆?某杉?[m\n",i++);
printf("平时 学习 测验 期末成绩\n");
score[4]=0;
for(j=0;j<4;j++)
{
scanf("%f",&score[j]);
score[4]+=score[i]*ratio[j];
}
printf("总评成绩为:%6.1f\n",score[4]);
printf("\n按空格键继续,其它键退出");
con_key=getch();
}
编译信息:
/usr/lib/gcc-lib/i586-thiz-linux/3.3.1/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
/tmp/ccBeakGk.o(.text+0x3d): In function `mian':
: undefined reference to `clrscr'
/tmp/ccBeakGk.o(.text+0xe6): In function `mian':
: undefined reference to `getch'
collect2: ld returned 1 exit status
而后man getch 信息是(部分):
NAME
getch, wgetch, mvgetch, mvwgetch, ungetch, has_key - get (or push back)
characters from curses terminal keyboard
SYNOPSIS
#include <curses.h>
int getch(void);
int wgetch(WINDOW *win);
int mvgetch(int y, int x);
int mvwgetch(WINDOW *win, int y, int x);
int ungetch(int ch);
int has_key(int ch);
不知如何是好