Ok I have a function
Code:
int stylecodes(char *input, char *out, int max) {
int c = 0;
char *str = input;
memset(out,'\0',max);
unsigned int i = 0;
for (i = 0; i < strlen(input); ) {
if (strncmp(str,"%c%",3)==0) {
snprintf(out,max,"%s%c",out,3);
str+=3;
c++; i+=3;
} else if (strncmp(str,"%b%",3)==0) {
snprintf(out,max,"%s%c",out,2);
str+=3;
c++;i+=3;
} else if (strncmp(str,"%o%",3)==0) {
snprintf(out,max,"%s%c",out,15);
str+=3;
c++;i+=3;
} else if (strncmp(str,"%u%",3)==0) {
snprintf(out,max,"%s%c",out,31);
str+=3;
c++;i+=3;
} else if (strncmp(str,"%i%",3)==0) {
snprintf(out,max,"%s%c",out,22);
str+=3;
c++;i+=3;
} else {
snprintf(out,max,"%s%c",out,str[0]);
str++;
i++;
}
}
return c;
}
now I want a fuction, which makes these steps backwards. Lets say the fuction replaces the string %c% with the ascii code 3 then I need a function which replaces the ascii code 3 back to
%c%
THX for everyone who can help me!