I have a text file I want to input into my program but I don't know the directory Visual C++ reads files from or how to find out. I'm sure it's obvious but I can't figure it out.
When you create a "Project", you give it a directory, say D. When you build the project, it will create a subfolder, depending on what type of build you do. If you do a Debug build, it will create D/debug. If you do a Release build, it will create D/release. This is where your actual ".exe", ".lib", ".dll", etc., files will be created. This is also the default "current working directory" that the program will start in. So, put whatever files you need to read/write from/to in the debug or release folder, depending on what type of build you do.
Alternatively, I'm pretty sure there is a way to change the working directory of the program when you run/debug it. Look around in the "Project Properties", etc., windows, or just search the documentation for it.
As for your other problem
I tried a few fixes and ended up with some unexpected outputs but I can't seem to get it to work.
Explain precisely what your "unexpected outputs" are. How is "test" declared? It isn't shown in your above code.
Code:
if (temp) test[index] = 1;
else test[index] = 0;
I imagine what you want the above code to do something like
Code:
if ( temp is the character '1' )
set test[index] to 1
otherwise
set test[index] to 0
but that's not what its doing. It's doing this
Code:
if ( temp is any character besides NULL character '\0' )
set test[index] to 1
otherwise
set test[index] to 0
To fix it, be more explicit in your if condition, i.e. dont just do "if (test)".