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

关于textbackground的有关问题

2012-05-01 
关于textbackground的问题今天接触一下程序:(实现Press any key to change color的功能)#include conio.h

关于textbackground的问题
今天接触一下程序:(实现Press any key to change color的功能)
#include "conio.h"
#include "stdio.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();/*输入字符看不见*/
  }
}
编译时出现这样的错误:
Compiling...
Cpp1.cpp
D:\vc++6.0\Cpp1.cpp(8) : error C2065: 'textbackground' : undeclared identifier
Error executing cl.exe.

Cpp1.obj - 1 error(s), 0 warning(s)
我查阅了某资料如下:
textbackground() 文本背景函数
功能: 函数textbackground()设置字符屏幕下文本背景颜色(或字符背景颜色)。
用法: 此函数调用方式为void textbackground(int bcolor);
说明: 参数bcolor 的有效值取表1-4背景颜色(即宏名)或等价值。
表1-4 背景颜色与等价值
-------------------------------------------------
  背景颜色 等价值 含 义
-------------------------------------------------
  BLACK 0 黑
  BLUE 1 蓝
  GREEN 2 绿
  CYAN 3 青
  RED 4 红
  MAGENTA 5 洋红
  BROWN 6 棕
-------------------------------------------------

调用该函数只影响后续写的字符背景颜色,而不改变当前显示在屏幕上的字符背景颜色。
  这个函数对应的头文件是conio.h
返回值: 无
例: 设置文本背景颜色为蓝色:
  textbackground(BLUE));


我的疑问:
1 我该如何做才能实现“Press any key to change color”的功能;
2 在VC++6.0中运行,这种颜色变化在哪可以体现呢?
3 textbackground(BLUE));/*我在运行时,有一提示:BLUE未定义,为什么?*/

[解决办法]
这个TC是支持的GDI,你放VC上跑有什么用

[解决办法]

vc6.0不支持TC下的图形相关的编程的,像#include<graphics.h>都是不行的。
如果非要用,考虑boost库(但非标准库,需另行安装!)

热点排行