Q:

fopen trying to access a different folder

I'm learning how to do file operations and whilst using fopen I seem to have encountered a problem. My project is in 'C:\Users\Bob\Documents', however, when I use fopen, it saves or tries to access files from  C:\Users\Bob\Documents\Debug. Debug is a folder in my Documents. 

How can I have my program access files from C:\Users\Bob\Documents only and not from the Debug folder.
Is there a way to specify different locations to save or access files from, instead of the current directory where my project is.
int main(){

FILE *fpointer;
char ch;
fpointer = fopen("test.txt", "r");

while(1){
    ch = fgetc(fpointer);
    if( ch == EOF){
        break;
    }
    printf("%c", ch);
}

return 0;
}

A:

Since you don't pass a path to fopen it will open files in the current working directory, which happens to be the Debug directory in your case.
Pass a full path instead, e.g.
fpointer = fopen("C:\\Users\\Bob\\Documents\\test.txt", "r");`

or change the working directory (either programatically, or in your IDE settings).

A:

A lot of what you are asking depends on your development environment.
Your development environment should be offering you some means to somehow configure how your program is launched, by modifying something called "debug configuration" or "launch configuration" or something along these lines.  Note that these options are different from the general options of the development environment, because they differ from project to project.
Right now it appears that nothing is configured, so the current directory of your application is the same directory as the directory where the .exe file is.  Since you are running your debug build, the .exe file is generated under Documents\Debug, and that's its working directory.  So, in the launch configuration specify that you want its working directory to be in C:\Users\Bob\Documents.
Alternatively, you can of course try opening "..\test.txt", but this will fail if you ever try to run your .exe under deployment conditions, where both the .exe and "test.txt" are probably going to be in the same directory.

