#include <stdio.h>
void squeeze(char s[], int c)
{
int i, j;
for(i = j = 0; s[i]!= '\0'; i++)
{
if (s[i] != c)
{
s[j++] = s[i];
}
}
s[j] = '\0';
printf("%s\n", s);
}
int main(void)
{
squeeze("asfafsdfsaaaasdfsd", 'a');
}
I run this program in mac, and it looks like the problem comes from the line: s[j++] = s[i]
but I don't know why.
Thanks!