I want to calculate the length of an char array in C with a while loop.
But If I insert otto
it returns the length of 5
. Shouldn't be 4
the right answer?
char eingabe[255];
printf("geben Sie eine Zeile ein:");
fgets(eingabe, 255, stdin);
int i = 0;
while (eingabe[i] != '\0')
{
++i;
}
printf("Laenge: %d\n", i);