如何让最后一个字母闪烁?
How to make the last letter blink?
我最近创建了这个显示字符串最后一个字母的程序。使用此代码:
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char text[255];
int length= strlen(text);
char lastchar=text[length-1];
gets(text);
cout<<lastchar;
getch();
}
如果我使用 textattribute
或 textcolor+128
并将 cout
更改为 cprintf(lastchar)
,我会收到一条错误消息:
cannot convert int to const* char" and "type mismatch in parameter '___format' in call to 'cprintf(const char*,....)'
这就是您要查找的内容:
//---------------------------------------------------------------------------
#include<conio.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
for (int i=32;i<256;i++)
{
textcolor(i);
cprintf("%c",i);
}
getch();
return 0;
}
//---------------------------------------------------------------------------
颜色设置为:
textattr(full_attribute);
textcolor(font_color);
textbackground(background_color);
闪烁在我的控制台 (Win7) 上不起作用,所以如果您遇到同样的问题,您需要为自己制作动画,试试这个:
//---------------------------------------------------------------------------
#include<conio.h>
#include<dos.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
char *txt="text[=12=]";
_setcursortype(0); // hide cursor
for (;;)
{
gotoxy(1,1); // print position
textattr(7); // white on black
cprintf("%s",txt);
sleep(1); // wait 1 sec
gotoxy(1,1); // print position
textattr(0); // black on black
cprintf("%s",txt);
sleep(1);
if (kbhit()) { getch(); break; } // stop on any key hit
}
// restore console properties
textattr(7);
_setcursortype(1);
return 0;
}
//---------------------------------------------------------------------------
你可以使用textcolor();
128代码是turbo c++中的闪烁代码
#include<conio.h>
#include<stdio.h>
int main(){
clrscr();
textcolor(128+6); // or textcolor(134) [128:blinking and 6:brown color]
cprintf("My name is Prashant");
getch(); }
如需更多帮助,请右键单击 turbo C++ window 并键入 textcolor();
我最近创建了这个显示字符串最后一个字母的程序。使用此代码:
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char text[255];
int length= strlen(text);
char lastchar=text[length-1];
gets(text);
cout<<lastchar;
getch();
}
如果我使用 textattribute
或 textcolor+128
并将 cout
更改为 cprintf(lastchar)
,我会收到一条错误消息:
cannot convert int to const* char" and "type mismatch in parameter '___format' in call to 'cprintf(const char*,....)'
这就是您要查找的内容:
//---------------------------------------------------------------------------
#include<conio.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
for (int i=32;i<256;i++)
{
textcolor(i);
cprintf("%c",i);
}
getch();
return 0;
}
//---------------------------------------------------------------------------
颜色设置为:
textattr(full_attribute);
textcolor(font_color);
textbackground(background_color);
闪烁在我的控制台 (Win7) 上不起作用,所以如果您遇到同样的问题,您需要为自己制作动画,试试这个:
//---------------------------------------------------------------------------
#include<conio.h>
#include<dos.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
char *txt="text[=12=]";
_setcursortype(0); // hide cursor
for (;;)
{
gotoxy(1,1); // print position
textattr(7); // white on black
cprintf("%s",txt);
sleep(1); // wait 1 sec
gotoxy(1,1); // print position
textattr(0); // black on black
cprintf("%s",txt);
sleep(1);
if (kbhit()) { getch(); break; } // stop on any key hit
}
// restore console properties
textattr(7);
_setcursortype(1);
return 0;
}
//---------------------------------------------------------------------------
你可以使用textcolor(); 128代码是turbo c++中的闪烁代码
#include<conio.h>
#include<stdio.h>
int main(){
clrscr();
textcolor(128+6); // or textcolor(134) [128:blinking and 6:brown color]
cprintf("My name is Prashant");
getch(); }
如需更多帮助,请右键单击 turbo C++ window 并键入 textcolor();