仲間。fopen の戻り値は、次の 2 つの点で異なることがわかりました。
1.
int main()
{
FILE* fp_file = NULL;
fp_file = fopen(file_path, "wb");
if(NULL == fp_file)
return RET_NULL_POINT;
else
return RET_OK;
}
2.
int _open_file(const char* ps_file_path, const char* ps_open_mode, FILE* fp_arg)
{
if(NULL == ps_file_path || NULL == ps_open_mode)
{ return RET_INV_ARG;}
fp_arg = fopen(ps_file_path, ps_open_mode);
if(NULL == fp_arg)
{ return RET_NULL_POINT;}
else
{ return RET_OK;}// fp_arg is NULL after fopen, but it return RET_OK, why?
}
int main()
{
FILE* fp_file = NULL;
int i4_ret = 0;
i4_ret = _open_file((const char*)file_path, "wb", fp_file);
if(RET_OK != i4_ret)
{// do sth NG}
else
{// do sth OK}
......//NULL_POINT exception will be caused at some place below.
}
2) の file_path は 1) と同じです。1) の結果は RET_OK を返し、2) の i4_ret の結果は RET_OK ですが、fp_file は NULL です。1) の fp_file が正しい値なのに、2) では NULL になっている理由を知りたいのですが? 1) と 2) で fopen の引数に違いはありません。