Q:

How to open file inside folder in current directory using fopen

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.

A:

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.

