Somebody somewhere sometime somehow wants this algorithm [translation: I'm too tired to remember]
(please note: algorithm - no letter y; non-rhythmic in all ways)
PHP Code:// returns number of replacements, -1 for error
int replacech(char *t, unsigned char old, unsigned char new){
char *buf;
int i=0;
if(t==NULL || old < 1 || new < 1) return (-1);
while (strchr(t,old) != NULL){
buf = strchr(t,old);
*buf = new;
i++;
}
return i;
}




Reply With Quote