Hi everyone! Is there any way to print out only the "full spaces" of the array?
Basically I have a txt file with some that looks like that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Order: 163
Date: 19 3 2017
Color: Red
SqMeters: 16.5
Price: 1650
Order: 164
Date: 19 3 2017
Color: Blue
SqMeters: 16
Price: 2400
Order: 179
Date: 19 3 2017
Color: Blue
SqMeters: 0.15
Price: 22.5
Order: 66
Date: 19 3 2017
Color: Green
SqMeters: 21.5
Price: 4300
Order: 165
Date: 19 3 2017
Color: Green
SqMeters: 165.15
Price: 33030
Order: 46
Date: 21 3 2017
Color: Blue
SqMeters: 12.5
Price: 1875
Order: 12
Date: 21 3 2017
Color: Red
SqMeters: 15
Price: 1500
|
Reading the txt file I create a 2D array (is mandatory for my assignment) like this one:
myRecordAll ordArrayAll[2][1000];
on the first column I put the orders from today, on the second one all of the other orders.
Everything is working perfectly but when it come to print the array there is a mistake. The problem is that I don't know how many "cells" of the array are full with data (order in this case) so I don't know how many cells to print.
At the same time both of the columns have different numbers of lines full of data. For example the position [1][14] is full with a order but the position [0][14] is empty.
So again my question is: is there any way to cout only the "cells" with data in it?
To print I use a simple loop.
1 2 3 4 5
|
for ( indexY = 0 ; indexY < 10 ; indexY++ ) // NotTodOrd
{
indexX = 1 ;
cout << ordArrayAll[indexX][indexY] ;
}
|
and
1 2 3 4 5
|
for ( indexY = 0 ; indexY < 10 ; indexY++ ) // TodOrd
{
indexX = 0 ;
cout << ordArrayAll[indexX][indexY] ;
}
|
Thanks in advance!!