Can someone please help me.. I have just figured out how to read all the values into a multidimensional array.. the thing is the table in the file can change at any time.. It can be any size.. Example:
Old Table to read (not a uniformed table, but all values print):
0 0
0 1
1 0
1 1
New Table to read (does not print all values.. not in order either):
0 0 0 0
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 0
1 1 1 1
Deformed Table:
0 6 12
1 7 13
2 8 14
3 9 15
4 10 16
5 11 17 18 //<-- See the deformed 18? table is not in uniformed rows and columns either.. so the last value never prints.
See how the dimensions of the table changed from 4x2 to 10x4? I want my program to adapt to such changes and be able to give the location of any value. Help please! I've been trying for so long.
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main()
{
int col, row, x, y;
x = y = 0;
row = 0;
col = 0;
fstream File;
File.open("test.txt", ios::in | ios::out);
string line;
while(getline(File, line))
{
x++;
istringstream tokenizer(line);
string token;
while(getline(tokenizer, token, ' '))
{
y++;
}
}
row …