Get a file location in C so the program can read files from this location
Hello, I'm currently working with a program where I ask the user to input a file path, such as C:\Users\Documents\Data. I take the input from the user and store it in a character array. This file path is a folder that contains several text files that I need to read data from.
I also have file pointers created so that the program can open and read each file and store the data in an array. For instance (I believe this is correct):
Code:
Data1Ptr = fopen( "Data1.txt", "r" );
i = 0;
while (!feof(Data1Ptr)) {
fscanf(Data1Ptr, "%d", &name);
Name[i] = name;
i++;
}
fclose(Data1Ptr);
(if this is incorrect, could y'all please let me know?)
How do I get the program to recognize that the char array with the user's input is a file location and to go to that location so that it can start opening and reading files? I'm not sure what functions there are that can do this. I read about stdin and stdout but I don't really know how to use them and I am not sure how they will help me here. I don't have very much experience with file IO's, and I've asked many people and consulted many places but I haven't found much that could help. Thank you in advance for the help!