What does fgets do?

Deadly 提交于 2019-12-04 21:23:12

fgets (unlike gets) includes the trailing \n corresponding to the return pressed at the end of the line. If you put 3 as the limit it truncates the string, discarding the \n.

From the manpage:

fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte ('\0') is stored after the last character in the buffer.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!