void encode(char* dst, const char* src) {
while (1) {
char ch = *src;
if (!ch || ch != '0','1','2','3') { //pseudo-code
*dst = 0;
return;
}
size_t count = 1;
while (*(++src) == ch)
++count;
*(dst++) = ch;
dst += sprintf(dst, "%zu", count);
}
How can I say, ch
does not equal a number.. then return. I am trying to get rid of the infinite loop as well.