Public feed
#529514
#include <stdio.h>#include <string.h>void kolorprint(char* msg); char * kolors[] = { "padding", "darkred", "Red", "Orange", "Brown", "Yellow", "Green", "Olive", "Cyan", "Blue", "darkblue", "Indigo", "Violet", "White", "Black", NULL };int main(int argc, char* argv[]){ int i; if (argc <= 1) { printf("insufficient arguments\n"); return 1; } else { printf("[list][size=9]"); kolorprint(argv[1]); printf("[/size][/list]\n"); } return 0;}void kolorprint(char* msg){ int i, x = 1; for(i = 0; i < strlen(msg); i++, x++) { if (msg[i] == 0x20) { x--; printf("%c", 0x20); } else { printf("[color=%s]%c[/color]", kolors[x], msg[i]); } if (x >= (sizeof(kolors) / sizeof(char*) - 2)) x = 0; /* * each element of kolors, since they are pointers, are only 4 bytes. * thus, when I want to count the elements I say sizeof(kolors) / 4 * one minus for the null and the other because of the start-at-zero thing. * edit: sizeof(char*) so it wont break on 64 bit. */ }}