question about this loop:

first loop iterates through data by the day of an input file: outputs to a diff file
second loop iterates through the trucks in input file:also outputs answer
my question is this, i don't want to use vector for second loop, so how can i make a loop with this exact variable without using vectors?
i have tried so many things but it keeps saying: "truckWeight can't be used as function

1
2
3
4
5
6
7
8
9
10
//for loop for day 
 for (d = 0; d < 7; d++){
     outFile << "Statistics for " << dayOfWeek[d]<< ":" << endl; 
     outFile << "Trucks with Fines: " << endl; 
 
//for loop for truck 
 for (t = 0; t < truckWeight; t++) {
     currentTruckWeight = truckWeight(t).at(d); 

     }
Last edited on
What's truckWeight's type? Is it a vector? If so, maybe you wanted to write:
for (t = 0; t < truckWeight.size(); t++).

Also set currentTruckWeight like:
currentTruckWeight = truckWeight[t];
Last edited on
it's an int
If truckWeight is an int then what is the meaning of truckWeight(t).at(d)?
You can't do such things with ints... :/
Last edited on
i don't want to use a vector b/c i've been putting it inside another vector, and i don't want it that messy, so i changed truckWeight into int so that i can make it easier for me to understand my own program, however truckWeight(t).at(d) is what it looked like before i turned it into int
Last edited on
LOL! Ok... so, what you need is a 2D-array to store truck weights? How many trucks do you have? Is it a number known at compilation time? If so, let's say this is const int truck_count=50; //or anything you want... , you can declare a 2D-array for your problem like this: int truck_weight[7][truck_count]; (7 days, truck_count trucks, for a total of 7*truck_count ints in your array)
Last edited on
i realize what my mistake was and i appreciate all the input
thank you very much (:
Topic archived. No new replies allowed.