Question
C++ help So I am not extracting my code right from my .dat file, it's opening but when I output it my vector is 10,000
C++ help
So I am not extracting my code right from my .dat file, it's opening but when I output it my vector is 10,000 elements from 0 to 9,999. Why is it doing this rather than reading from my file? Here is my code:
#include
using namespace std;
int main() {
int rows = 25; int cols = 0; string filename; int min; int max;
while (rows != cols || cols == 2 * rows) { cout << "enter the number of rows" << endl; cin >> rows; cout << "enter the number of columns" << endl; cin >> cols; } vector
ifstream myReadFile; myReadFile.open("map-input-100-100.dat");
while (!myReadFile.eof()) {
for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { myReadFile >> data[i][j]; } }
for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { cout << data[i][j] << " "; } }
system("pause"); return 0;
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started