I read a string using fgets. It prints correctly but if i try to output the length using a strlen or a while until NULL it returns a bad value. Does fgets not end the string with NULL?
char word[256];
fgets(word, sizeof(word), stdin);
while(word[i])
i++;
printf("%d",i);
For the string aba it outputs 40.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…