I want to open a file that is inside a folder in the current working directory like so:
fopen("/folder/file.txt","r");
I'm unable to do so in this way, i get a "No such file or directory" error.
How can i do this properly?
Thank you in advance for any help.
You have to mention that is a current directory. Try this,
fopen("./folder/file.txt","r");
Or
fopen("folder/file.txt","r");
If you mentioning like this /folder/file.txt
it will search the directory from the root directory. So this is the reason for getting the error.
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