Hi im writing program from codewars site.
The aim of this program is to replace # into \b. After compiling in Visual Studio I am getting proper result but codewars site give me wrong result.
Code:
char *strclr(const char *s)
{
char *r = (char*)malloc(sizeof(char)*strlen(s) + 1);
memset(r, '\0', strlen(s) + 1);
for (; *s!='\0'; s++)
{
if (*s == '#')
strncat(r, "\b", 1);
else
strncat(r, s, 1);
}
return r;
}
I think that I could make one change in this program if *s=='#' decrease --r but it not work properly. Can you help me with this