How to open a text file that's not in the same folder?

Posted by nunos on Stack Overflow See other posts from Stack Overflow or by nunos
Published on 2010-05-27T21:49:53Z Indexed on 2010/05/27 22:01 UTC
Read the original article Hit count: 93

Filed under:
|
|

Since C it's not a language I am used to program with, I don't know how to do this.

I have a project folder where I have all the .c and .h files and a conf folder under which there is a config.txt file to read. How can I open that?

FILE* fp = fopen("/conf/config.txt");

if (fp != NULL)
{
    //do stuff
}

else
   printf("couldn't open file\n");

I keep getting the error message. Why?

Thanks.

© Stack Overflow or respective owner

Related posts about c

    Related posts about file