一直想实现那种在控制台里花哨显示的功能,
最近终于小试了下,其实没什么特别的,
就是向上移动光标…
/*description : printf special method
*
* date : 2015/12/04
*
*
*/
#include <stdio.h>
#include <string.h>
int main()
{
printf("\033[2J"); // clear the screen
printf("\033[2;5H"); // set the postion of cursor
printf("\033[0;32;32m"); // set the color green
printf("\033[K"); // clean the remains of the line
printf("\033[4m"); // set the underline
printf("hello world\n");
printf("\033[0m"); // close all of the attributes
printf("\033[2A"); // up the cursor
printf("hello world again");
printf("\033[3B"); // down the cursor
return 0;
}
输出如下,当然颜色我就不贴图片了
hello world again
hello world