这个C语言代码是对的,为什么在我的编译器上还是错误,帮忙修正下。

来源:百度知道 编辑:UC知道 时间:2024/05/25 14:36:23
这是代码:

#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();
}
}

错误的提示;
error C2065: 'textbackground' : undeclared identifier
执行 cl.exe 时出错.

2323.exe

textbackground没有定义~~~

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();
}
这句里面可以看到,在for语句循环里调用了名为textbackground的函数,参数为color

你没有定义好textbackground怎么执行?

#include<conio.h>
void main()
{
int color;
for(color=0;color<8;color++)
{
textbackground(color); //首先请问下,你这个涵数的声明定义在什么地方
printf("This is color %d\r\n",color);
printf("Press any key to continue\r\n");
getch();
}
}
改成这样
#include <stdio.h>
void textbackground(int color);
void main()
{
int color;
for(color=0;color<8;color++)
{
textbackground(color); //首先请问下,你这个涵数的声明定义在什么地方
printf("This is color %d\r\n",color);
printf("Press any