unresolved external symbol _clrscr

来源:百度知道 编辑:UC知道 时间:2024/05/22 22:59:19
#include <conio.h>z
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#define N 81
void readwriteDAT();

void chg(char*s)
{
}

main( )
{
char a[N];
clrscr();
printf("Enter a string : "); gets(a);
printf("The original string is : "); puts(a);
chg(a);
printf("The string after modified : ");
puts (a);
readwriteDAT() ;
system("pause");
}

void readwriteDAT()
{
int i ;
char a[N] ;
FILE *rf, *wf ;

rf = fopen("in.dat", "r") ;
wf = fopen("out.dat", "w") ;
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%s", a) ;
chg(a) ;
fprintf(wf, "%s\n", a) ;
}
fclose(rf) ;
fclose(wf) ;
}

上面是程序
为什么在连接的时候没问题,
编译的时候出现
----------------

缺少静态库文件*.lib,函数clrscr可能在头文件里声明,但未定义,需要指定相应的库

把 clrscr();
改写为
system("CLS");

1>main.cpp
1>e:\documents\visual studio 2008\projects\baidu\main.cpp(15) : error C3861: “clrscr”: 找不到标识符
1>e:\documents\visual studio 2008\projects\baidu\main.cpp(22) : error C3861: “system”: 找不到标识符

解决方案如下:
1.添加#include <stdlib.h>可解决无法识别system指令的问题
2.用system("cls")来替换clrscr() 这个已经被淘汰了的函数。
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

#define N 81
void readwriteDAT();

void chg(char*s)
{
}

void main( )
{
char a[N];
//clrscr();
system("cls");
printf("Enter a string : "); gets(a);
printf("The original string is : "); puts(a);
chg(a);
printf(&qu