fopen() 总是返回 0x0

问题描述

我正在尝试打开一个文本文件并逐个字符地读取它。 这是我的代码

printf( "opening the file test.txt in read mode" ) ;
fp = fopen ( "test.txt","r" ) ; // opening an existing file
if ( fp == NULL )
{
  printf ( "Could not open file test.txt" ) ;
  return 1;
}
printf( "Reading the file test.txt" ) ;
while ( 1 )
{
  c = fgetc ( fp ) ; // reading the file
  if ( c == EOF )
    break ;
  printf ( "%c",c ) ;
}
printf("Closing the file test.txt") ;
fclose ( fp ) ; // Closing the file

文件 test.txt 与程序 (exe) 存在于同一目录中。

当我执行它时,fopen() 总是返回 NULL。有人可以帮助我,可能有什么问题吗? 谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)