ISO C POSIX.1 XPG4 XPG4.2 C99 Single UNIX Specification、バージョン 3 Language Environment® 両方 形式 #include <stdio.h> char *fgets(char * __restrict__string, int n, FILE * __restrict__stream); #define _OPEN_SYS_UNLOCKED_EXT 1 #include <stdio.h> char *fgets_unlocked(char ...
从文件结构体指针stream中读取数据,每次读取一行。读取的数据保存在buf指向的字符数组中,每次最多读取size-1个字符(第size个字符赋值‘\0'),如果文件中的该行,不足size个字符,则读完改行就结束,如果函数读取成功,则返回指针buf,失败则返回NULL。 如果使用fges()读取某个文件。 (1)第一次读取的size为5,而文件的...
// crt_fgets.c // This program uses fgets to display // a line from a file on the screen. // #include <stdio.h> int main( void ) { FILE *stream; char line[100]; if( fopen_s( &stream, "crt_fgets.txt", "r" ) == 0 ) { if( fgets( line, 100, stream ) == NULL) ...
C // crt_fgets.c// This program uses fgets to display// the first line from a file.#include<stdio.h>intmain(void){ FILE *stream;charline[100];if( fopen_s( &stream,"crt_fgets.txt","r") ==0) {if( fgets( line,100, stream ) ==NULL)printf("fgets error\numChars");elseprintf...
// crt_fgets.c // This program uses fgets to display // a line from a file on the screen. // #include <stdio.h> int main( void ) { FILE *stream; char line[100]; if( fopen_s( &stream, "crt_fgets.txt", "r" ) == 0 ) { if( fgets( line, 100, stream ) == NULL) ...
// crt_fgets.c // This program uses fgets to display // a line from a file on the screen. // #include <stdio.h> int main( void ) { FILE *stream; char line[100]; if( fopen_s( &stream, "crt_fgets.txt", "r" ) == 0 ) { if( fgets( line, 100, stream ) == NULL) ...