Here's my question: I have some relative paths saved in a matrix of strings. Depending on the user choiche, I have to open a certain file. The problem is that, when I use the fopen function, the file pointer doesn't point to anything. Here's a sample of the code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_PATH 100
///Global matrix of strings, containing the paths used in fopen() function
char paths[MAX_PATH][3] = {{"c:\\Users\\ThisPc\\Desktop\\file1.txt"},
                           {"c:\\Users\\ThisPc\\Desktop\\file2.txt"},
                           {"c:\\Users\\ThisPc\\Desktop\\file3.txt"}};
int main(){
    ///Declaring and initializing the 3 file pointers to NULL
    FILE *filepntr1 = NULL;
    FILE *filepntr2 = NULL;
    FILE *filepntr3 = NULL;
    ///Opening the 3 files with the correct arrays
    filepntr1 = fopen(paths[1], "w");
    filepntr2 = fopen(paths[2], "w");
    filepntr3 = fopen(paths[3], "w");
    ///Typing something on the files opened, just to check if the files where really opened
    fprintf(filepntr1, "hello");
    fprintf(filepntr2, "hello");
    fprintf(filepntr3, "hello");
    ///Closing the files
    fclose(filepntr1);
    fclose(filepntr2);
    fclose(filepntr3);
    return 0;
}
Obviously, the three files remain blank.
What am I doing wrong?
 
     
     
     
    