1.反顯示字符crusherhtml
#include <stdio.h> int main (int argc, char *argv[]) { printf("\033[7m more?\033[m \n"); return 0; }
2.應用反顯字符顯示當前時間:spa
#include <time.h> #include <stdio.h> #include <stdlib.h> int main() { unsigned int now_secs = time(0); char *strp = ctime(&now_secs); printf("Now time is \033[7m %s \033[m", strp); return 0; }
3.讀寫終端文件 並在另外一個窗口寫入hello.net
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> int main() { int fd = open("/dev/pts/1", O_WRONLY); if (fd == -1) { perror("open pts error\n"); } int res = write(fd, "hello", 5); if (5 != res) { perror("write error!\n"); } return 0; }