I don't understand why you use sizeof as argument, and why in this line if (i < (n - 1)) you need n-1?
Thanks.
I don't understand why you use sizeof as argument, and why in this line if (i < (n - 1)) you need n-1?
Thanks.
>I don't understand why you use sizeof as argument
sizeof str evaluates to 10. It's a nice easy way to pass the correct size of an array of char even if you decide to change the size for further testing.
>and why in this line if (i < (n - 1)) you need n-1?
If you allowed n characters to be read then there wouldn't be any room left for the null character that terminates a string.
My best code is written with the delete key.