Hello guys i began reading K&R but there problem in a code i dont really understand it here code of a sequeeze function
/* squeeze: delete all c from s */
void squeeze(char *buffer, int c)
{
int i, j;
for (i = j = 0; buffer[i] != '\0'; i++) {
if (buffer[i] != c)
buffer[j++] = buffer[i];
buffer[j] = '\0';
}
}
int main(void)
{
char name[]="NAME";
puts("Name Before Sequueze: \n");
puts(name);
squeeze(name,'N');
puts("Name After Sequueze: \n");
puts(name);
getchar();
return 0;
}
i dont really understand the code its the same string and everything how if i made 1st character whish is N it wont be delted i dont really quite get that thanks.