小例題,輸入一些字符以改變文字背景顏色。
題目:Press any key to change color, do you want to try it. Please hurry up!
1.程序分析:
2.程序源代碼:
/*摘自C語言網 www.dotcpp.com*/
#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();/*輸入字符看不見*/
}
}
例題來自C語言網。