c语言运行错误

来源:百度知道 编辑:UC知道 时间:2024/06/02 10:28:12
#include
void main(void)
{
int color;
for (color = 0; color < 8; color++)
{
textbackground(color);/*设置文本的背景颜色*/
cprintf("This is color %d\r\n", color);
cprintf("Press any key to continue\r\n");
getch();/*输入字符看不见*/
}
}
这个程序错在什么地方了 ?
给个正确的
最好给个正确的程序

这部份缺少需要包含的头文件~
#include <conio.h>
void main(void)
{
int color;
for (color = 0; color < 8; color++)
{
textbackground(color);/*设置文本的背景颜色*/
cprintf("This is color %d\r\n", color);
cprintf("Press any key to continue\r\n");
getch();/*输入字符看不见*/
}
}

getch(),getche(),getchar()的区别
getch()函数不将读入的字符回显在显示屏幕上
getche() 函数却将读入的字符回显到显示屏幕上。

getchar()函数也是从键盘上读入一个字符, 并带回显。它与前面两个函数
的区别在于: getchar()函数等待输入直到按回车才结束, 回车前的所有输入字 符都会逐个显示在屏幕上。但只有第一个字符作为函数的返回值。