I found when I use the fgets
function like so:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[10];
fgets(str, 5, stdin);
printf("%s", str);
system("PAUSE");
return 0;
}
If I input a 123456789
, it will output a 1234
. That's 4 characters - not the 5 I have defined in the function. What is happening to the fifth character?
edit: title updated