How to include .cfg file path for libconfig?

216 views Asked by At

I'm using libconfig. The file .cfg is in the same directory of the .c file. I want to read the .cfg from a specific path. For example i want that the file could be in the previous directory (not in the same directory of the .c file). How can I do it? Here is my code for reading .cfg file (it's standard code):

config_t cfg;
    config_setting_t *setting;

    config_init(&cfg);

    if(! config_read_file(&cfg, "file.cfg"))
    {

    fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg),config_error_line(&cfg), config_error_text(&cfg));
    config_destroy(&cfg);
    return(EXIT_FAILURE);

    }
0

There are 0 answers