现在的位置: 首页 > web前端 > 正文

关于textbackground的问题

2020年07月20日 web前端 ⁄ 共 1347字 ⁄ 字号 评论关闭

  函数textbackground()设置字符屏幕下文本背景颜色(或字符背景颜色)。


  textbackground是什么


  函数名:textbackground


  功能:选择新的文本背景颜色


  用法:voidtextbackground(intcolor);


  头文件:包含在conio.h头文件中,但是在vc的conio.h中找不到这个函数,TC中有;


  程序例:


  #include“stdio.h”


  #include“conio.h”


  intmain(void)


  {


  inti,j;


  clrscr();


  for(i=0;i<9;i++)


  {


  for(j=0;j<80;j++)


  cprintf("C");


  cprintf("\r\n");


  textcolor(i+1);


  textbackground(i);


  }


  getch();


  return0;


  }


  关于textbackground的问题


  今天接触一下程序:(实现Pressanykeytochangecolor的功能)


  #include"conio.h"


  #include"stdio.h"


  voidmain()


  {


  intcolor;


  for(color=0;color<8;color++)


  {


  textbackground(color);


  cprintf("Thisiscolor%d\r\n",color);


  cprintf("Pressanykeytocontinue\r\n");


  getch();


  }


  }


  编译时出现这样的错误:


  Compiling...


  Cpp1.cpp


  D:\vc++6.0\Cpp1.cpp(8):errorC2065:'textbackground':undeclaredidentifier


  Errorexecutingcl.exe.


  Cpp1.obj-1error(s),0warning(s)


  我查阅了某资料如下:


  textbackground()文本背景函数


  功能:


  用法:此函数调用方式为voidtextbackground(intbcolor);


  说明:参数bcolor的有效值取表1-4背景颜色(即宏名)或等价值。


  表1-4背景颜色与等价值


  -------------------------------------------------


  背景颜色等价值含义


  -------------------------------------------------


  BLACK0黑


  BLUE1蓝


  GREEN2绿


  CYAN3青


  RED4红


  MAGENTA5洋红


  BROWN6棕


  -------------------------------------------------


  调用该函数只影响后续写的字符背景颜色,而不改变当前显示在屏幕上的字符背景颜色。


  这个函数对应的头文件是conio.h


  返回值:无


  例:设置文本背景颜色为蓝色:


  textbackground(BLUE));


  总之,textbackground给大家简单的介绍了一些,希望大家多看看。


  

抱歉!评论已关闭.