I am have a trouble in using fopen() with relative path. I wanted to use fopen like this:
fopen("\\Saurabh\\pqrs.txt");
i am getting filePointer as null.
The situation arose because I am trying to create a setup or deployment project which has to read files. The file paths chosen by default after user executes setup are C:\Program Files\Setup.. (where exe is dumped). So I dumped the files in the same folder and gave path(fixed path or hardcoded) to those files in the program.
If the user selects some other path for installation, the program fails.
Is there any way I can fix this?
Two problems:
\\
.\\
you mean start from the root directory.Putting these together, I think you should write:
fopen("Saurabh\\pqrs.txt");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With