#include <stdio.h> #include <stdlib.h> int main() { FILE *p; char str[9]; if ((p = fopen("D:\\myname.txt", "r")) == NULL) { printf("无法打开此文件\n"); exit(0); } fgets(str, 10, p); puts(str); return 0; }