|
分享C語言printf控制臺花樣打印,可以彩色顯示。 - #include "../0_toolboxfile/myprintf.h" //相關(guān)函數(shù)的聲明
- //#include "../0_toolboxfile/myprintf.c" //相關(guān)函數(shù)的定義(很少這樣做,可能有重定義問題,解決方案:放在同名 myprintf.h 最后面包含)
- int main(void)
- {
- int a,b,c;
- myprintf_setStrFormat(0,0,RED_Char,BLUE_Back); //藍(lán)底紅字
- printf("彩色花樣打印\n");
- myprintf_setDefault(TRUE); //恢復(fù)正常打印
- printf("恢復(fù)正常打印\n");
- myprintf_color(YELLOW_Char,BLUE_Back,"y%%dou %c hh%daha",'A',52,87); //藍(lán)底黃字,只用到2個(gè)參數(shù)
- printf("你好,C語言\n");
- printf("輸入2個(gè)或以上數(shù)字回車:\033[");
- a=getchar()-48;
- scanf("%d",&b);
- c=a*b;
- printf("ans=%d\n",c);
- if(c%2==0)
- getch(); //等待按下任意鍵,再繼續(xù)執(zhí)行下面的語句,在<conin.h>文件里
- else
- system("pause"); //在命令行上輸出"按任意鍵繼續(xù)..."的文字,按任意鍵結(jié)束,在<windows.h>文件里
- return 0;
- }
復(fù)制代碼
|
|