Removing color codes from a char array in C -


i came problem stuck with. must remove color codes char array in c. let's message this:

[15:51:55] [error]: {ffffff}you have vehicle!r "police car (lspd)" (modelid: 596, vehicleid: 306) 

the color codes within { , } characters. wrote function, first argument original message, , second 1 array store original message without color codes.

void eliminarcodigoscolores(char *mensaje, char *destino) {     (int = 0; < strlen(mensaje); i++)     {         if ((mensaje[i] != '{' && mensaje[i + 7] != '}') || (mensaje[i - 1] != '{' && mensaje[i + 6] != '}') ||              (mensaje[i - 2] != '{' && mensaje[i + 5] != '}') || (mensaje[i - 3] != '{' && mensaje[i + 4] != '}') ||             (mensaje[i - 4] != '{' && mensaje[i + 3] != '}') || (mensaje[i - 5] != '{' && mensaje[i + 2] != '}') ||             (mensaje[i - 6] != '{' && mensaje[i + 1] != '}') || (mensaje[i - 7] != '{' && mensaje[i] != '}'))         {             *destino++ = mensaje[i];         }     } } 

it not work (the color codes not removed) , don't know what's wrong. there better or simpler way this?

thanks in advance.

i watch opening {, see if there's } 7 chars later, , skip whole bunch:

void eliminarcodigoscolores(const char *mensaje, char *destino) {     int = 0, j = 0;      while ( < strlen(mensaje) )     {         if ((i + 7 < strlen(mensaje)) &&             (mensaje[i] == '{') &&             (mensaje[i + 7] == '}'))         {             += 8;         }         else         {             destino[j++] = mensaje[i++];         }     }      destino[j] = 0; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -