Bruce
Bruce

Reputation: 35285

Error while opening a file inside a dll

I am opening a file inside a dll code. I am using fopen. The pointer returned by fopen is NULL. What am I doing wrong?

pFile = fopen("C:\\Users\\bruce\\Desktop\\log.txt","w");

I run the code with the debugger. The file gets created but the pointer returned by fopen is NULL which throws an exception when I use fprintf

Upvotes: 0

Views: 847

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 994021

After fopen() fails, the error result is stored in the errno global variable (be sure to #include <errno.h>). The strerror() function can convert the errno number into a human readable string.

Upvotes: 1

Related Questions