主页
C 语言
C 读取文件
c_demo_files_read
运行 ❯
×
更改方向
保存代码
更改主题
#include
int main() { FILE *fptr; // Open a file in read mode fptr = fopen("filename.txt", "r"); // Store the content of the file char myString[100]; // Read the content and store it inside myString fgets(myString, 100, fptr); // Print file content printf("%s", myString); // Close the file fclose(fptr); return 0; }
Hello World!