1 #include <stdio.h> 2 #include <string.h> 3 4 int main(int argc, char **argv) 5 { 6 int i = 0, j = 0, str_len = 0; 7 8 if (1 == argc) 9 { 10 printf("no argument\n"); 11 return -1; 12 } 13
14 srand(time(NULL)); 15 for (i = 1; i < argc; i++) 16 { 17 str_len = strlen(argv[i]); 18 for (j = 0; j < str_len; j++) 19 { 10 printf("\033[%dm%c", rand()%8+30, argv[i][j]); 21 } 22 printf(" "); 23 } 24 25 printf("\033[0m\n"); 26 27 return 0; 28 }
\033[0m 表示恢復默認