Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one help me? I want to know how really that code works.

What I have tried:

char filename[MAX_PATH] = "D:\\example\\test.txt";
FILE *fp;
fp = fopen_s(&fp, filename, "r");

// want to check the given path is correct or not with out exceptions. for eg: filename[] = "A:\\file\\test.txt" which is a invalid path, how to know that?
Posted
Updated 4-Jun-18 19:33pm
Comments
KarstenK 5-Jun-18 2:21am    
Why havent you read the documentation?
Richard MacCutchan 5-Jun-18 3:07am    
lol

1 solution

Look at the documentation: fopen_s, _wfopen_s[^]
Quote:
Return Value
Zero if successful; an error code on failure. See errno, _doserrno, _sys_errlist, and _sys_nerr for more information about these error codes.

The error code tells you why it failed: errno, _doserrno, _sys_errlist, and _sys_nerr[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900