I'm looking at string manipulation in C and I don't understand why the statement s1[i] = s1[++i];
won't replace the first H
by the next character e
. Take a look at the code :
#include <stdio.h>
main()
{
char s1[] = "Hello world !";
for(int i = 0; s1[i] != '\0'; ++i)
s1[i] = s1[++i];
printf("%s", s1);
}
It prints Hello world !
instead of el r