2010年12月29日 星期三

Cannot open that file

Cannot open that file.
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

1 則留言: