sorry if this is an amateur question but I am new to coding and I am trying to open/read a file through a function?
My code for the function is kind of like this:
struct_name ReadInFile(std::string fileName)
{
std::ifstream readFile("fileName");
assert(readFile.is_open());
...
...
}
but it fails at this assert stage? (I know assert isn't good coding practice!)
The main programme looks like this:
struct_name TESTING = ReadInFile("thefile.dat");
std::cout << TESTING.struct_variable;
I am not sure why the file won't open - I assume it's because it's not saved in the right place on my computer (I think it needs to be stored wherever my executable file gets built right?) but I have tried saving it in 50+ different locations and still nothing works!?
/Users/MyName/Library/Developer/Xcode/DerivedData
is where I'm told my build system is but I have saved it in numerous locations around here and still nothing!
I would really appreciate some help! Thank you so much