c语言clrscr()疑惑

来源:百度知道 编辑:UC知道 时间:2024/05/27 05:29:27
新建 文本文档.obj : error LNK2001: unresolved external symbol _clrscr
Debug/新建 文本文档.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

新建 文本文档.exe - 1 error(s), 0 warning(s)
不知道问什么会这样子?
源代码如下:
#include <conio.h>

int main(void)
{
int i;
clrscr();
for (i = 0; i < 20; i++)
cprintf("%d\r\n", i);
cprintf("\r\nPress any key to clear screen");
getch();
clrscr();
cprintf("The screen has been cleared!");
getch();
return 0;
}

#clude <stdio.h>
把它也包含进去

clrscr()函数的头文件#include <conio.h> 只有在C中才能用,VC却不能解释,有一个比较好的函数,同样能实现清屏的功能。

这就是: system("CLS");它的头文件是#include<windows.h>。

程序示例:

#include <conio.h>
#include<windows.h>

int main(void)
{
int i;

system("CLS");
for (i = 0; i < 20; i++)
cprintf("%d\r\n", i);
cprintf("\r\nPress any key to clear screen");
getch();

system("CLS");
cprintf("The screen has been cleared!");
getch();
return 0;
}