int main() { char filename[80]; FILE *fp; printf("input file name: "); fgets(filename, 79, stdin); fp = fopen(filename, "r"); assert(fp != NULL); fclose(fp); }
C:\SVN\book\C>ls -l fgets.c -rw-rw-rw- 1 user group 225 Dec 29 17:23 fgets.c C:\SVN\book\C>a.exe input file name: fgets.c Assertion failed: fp != NULL, file fgets.c, line 10
filename 是 "fgets.c\n"
回覆刪除