cls实际上是clear screen的简写
为什么clrscr()功能没有用,编译器还报错,对不?呵呵
其实,有两个问题:
1、clrscr()是在头文件conio.h下的函数,原型是void clrscr(void)。
于是,你【好像懂了】,便在你原有程序的基础上加了一个#include<conio.h>
但是很不幸,编译器依然报错,甚至发出“’clrscr’ undefined; assuming extern returning int”的错误提示,对不?
于是你需要了解第2点了
2、在VC平台下,显然是不能使用控制台语句conio的,而在TC平台则可以
(想要更具体,请参照c free 标准,他会对你帮助很大)
好了,废话结束,我帮你修改下:
#include<stdio.h>
#include<stdlib.h>
int main()
{
char ch;
printf("input ch:");
ch=getchar();
system("cls"); //这个与你的clrscr()功能差不多,头文件stdlib.h
printf("%c %c\n",ch,ch);
printf(" %c %c\n",ch,ch);
printf(" %c %c\n",ch,ch);
printf(" %c\n",ch,ch);
printf(" %c %c\n",ch,ch);
printf(" %c %c\n",ch,ch);
printf("%c %c\n",ch,ch);
return 0;
}
#include <windows.h>
system("cls");
程序额外运行系统程序执行清屏操作,延长了程序执行时间。
#include <stdlib.h>
#include <stdio.h>
int main(){
int i,j;
printf("input ch:");
printf("input ch:");
printf("input ch:");
i = system("cls");
j = system("pause");
printf("%d\n%d\n",i,j);
return 0;
}