首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

书下有有关问题!

2012-09-16 
书上有问题!求助!#includestdio.hvoid main(){FILE *fpchar str[11]if((fpfopen(file1.txt,rt))

书上有问题!求助!
#include<stdio.h>
void main()
{FILE *fp;
 char str[11];
 if((fp=fopen("file1.txt","rt"))==NULL)
 { printf("This file Cannot be opened! any key exit!");
  getch();
  exit(1);
 }
 fgets(str,11,fp);
 printf("%s",str);
 fclose(fp);
}




--------------------Configuration: helloc - Win32 Debug--------------------
Compiling...
helloc.cpp
D:\VC语言\helloc\helloc.cpp(7) : error C2065: 'getch' : undeclared identifier
D:\VC语言\helloc\helloc.cpp(8) : error C2065: 'exit' : undeclared identifier
执行 cl.exe 时出错.

helloc.exe - 1 error(s), 0 warning(s)


还要定义的?

[解决办法]
_getch, _getche
Get a character from the console without echo (_getch) or with echo (_getche).

int _getch( void );

int _getche( void );

Routine Required Header Compatibility 
_getch <conio.h> Win 95, Win NT 
_getche <conio.h>
=========================
exit, _exit
Terminate the calling process after cleanup (exit) or immediately (_exit).

void exit( int status );

void _exit( int status );

Function Required Header Compatibility 
exit <process.h> or <stdlib.h> ANSI, Win 95, Win NT 
_exit <process.h> or <stdlib.h>
==================
你要包含头文件啊
[解决办法]
1)getch-->getchar? #include <stdio.h>
2)exit--> #include <stdlib.h>

热点排行
Bad Request.