.net中,怎么使用FILE

oplm0082 2004-08-15 10:17:48
从vc6.0转成.net.有一部分文件读取的部分。
FILE *pStream;
pStream = fopen(fileName,"r+");
if ( pStream == NULL) {
AfxMessageBox( "Open file error!" );
return FALSE;
}
else{
CString strToRead;
fseek( pStream, 0L, SEEK_SET );
fscanf( pStream, "%s", strToRead );

}
fclose(pStream);
然后会提示内存读取错误,请问这是怎么回事,如何解决??
ps:如果不调用fscanf语句,就不会出现错误。
...全文
92 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
真相重于对错 2004-08-16
  • 打赏
  • 举报
回复
FILE *pStream= NULL <---------------
pStream = fopen(fileName,"r+");
if ( pStream == NULL) {
AfxMessageBox( "Open file error!" );
return FALSE;
}
else{
CString strToRead;
fseek( pStream, 0L, SEEK_SET );
fscanf( pStream, "%s", strToRead );

}
fclose(pStream);

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧