I'm trying to read integers in a .txt file into a 2 dimensional array (map).
Here is the function:
void loadmap(int mapnum)
{
int x;
ifstream inFile;
inFile.open("level1.txt");
if (!inFile)
{
cout << "Unable to open file";
//exit(1); // terminate with error
}
for(int countline = 0; countline <= 9; countline++)
{
for(int count = 0;count <= 9; count++)
{
while(inFile >> x)
{
map[count][countline] = x;
}
}
}
memcpy(resetmap,map,sizeof resetmap);
inFile.close();
}
The problem is, the function does not seem to find the file (level1.txt). The file is in the root folder for the program. The console just outputs "unable to open file." and all the values in the array (map) default to 0.
Why might this be?