更新时间:2023-02-12 18:39:40
使用与fgets
来从文件中读取字符串中的 C
Use fgets
to read string from files in C.
是这样的:
#include <stdio.h>
#define BUZZ_SIZE 1024
int main(int argc, char **argv)
{
char buff[BUZZ_SIZE];
FILE *f = fopen("f.txt", "r");
fgets(buff, BUZZ_SIZE, f);
printf("String read: %s\n", buff);
fclose(f);
return 0;
}
避免了简单
安全检查。
Security checks avoided for simplicity.