Re: [問題] fopen回傳null該怎麼辦
※ 引述《QQ29 (我愛阿蓉)》之銘言:
try this:
#include <stdio.h>
#include <string.h>
int main() {
FILE * fout = NULL;
int err = fopen_s( &fout, "C:\\test.bin", "wb" );
if( fout ) {
fprintf( stderr, "y\n" );
fclose( fout );
} else {
perror( strerror( err ) );
}
return 0;
}
====
如果 Visual C++ 跟你靠北 fopen 不安全
有時候聽它的話也不錯
MinGW 就沒辦法了
--
自High筆記(半荒廢)
http://legnaleurc.blogspot.com/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 211.74.131.25
討論串 (同標題文章)
完整討論串 (本文為第 2 之 3 篇):
6
15
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章