fgets, fputs, ferror, feof, stdin, stdout, EOF, fopen, fclose, fgetc, fputc, getchar, putchar
注意区分
gets, fgets, fgetc, getc, getchar
puts, fputs, fputc, putc, putchar
fgets
function<cstdio>
char * fgets ( char * str, int num, FILE * stream );
Get string from stream
Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or a the End-of-File is reached, whichever comes first.
A newline character makes fgets stop reading, but it is considered a valid character and therefore it is included in the string copied to str.
A null character is automatically appended in str after the characters read to signal the end of the C string.
fputs
function<cstdio>
int fputs ( const char * str, FILE * stream );
Write string to stream
Writes the string pointed by str to the stream.
The function begins copying from the address specified (str) until it reaches the terminating null character ('\0'). This final null-character is not copied to the stream.
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
<cstdio>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步