Input the name of a file to be read in

I need to read in a file, but the user inputs the files name
this is what i have so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cout << "Please enter the name of the file including '.txt',\n"
     << "that you wish to be used as the numbers." << endl;
		
		cin >> filename;
		
				ifstream inFile;
				inFile.open(filename); //opening the file
				for (i = 0; i < maxr; i++);
				{ 
					for (j = 0; j < maxc; j++)
					{
						inFile >> np[i][j];
					}
				}
				if (inFile.fail())
				{
					cout<< "The file was not found" << endl;
					system("pause");
					exit(1);
				};
				inFile.close();

It's opening the file(i assume becuase it doesnt say it wasnt found), but not reading the numbers and storing them in the array correctly. it replaces all the numbers with -858993460
Last edited on
Topic archived. No new replies allowed.