A
Alan
I am having a strange problem with a vector. I am reading data in
from a file and putting it in the vector. On the third item read in,
it reaches the .push_back code. However, after that, I use .size(),
and it says that it only has two items. This is bizarre. Any
thoughts?
Code fragment may be found below. Thanks, Alan
while (inFile >> sensed_data.time >> sensed_data.sensor_who >>
sensed_data.aircraft_who {
// cout << "Reading input file\n";
if (sensed_data.time == last_clock)
{
cout << "Adding report to list\n";
cout << "Data to add: " << sensed_data.sensor_who << " "
<< sensed_data.aircraft_who << "\n";
sensor_reports.push_back (sensed_data);
cout << "# sensor reports = " << sensor_reports.size() <<
"\n";
}
from a file and putting it in the vector. On the third item read in,
it reaches the .push_back code. However, after that, I use .size(),
and it says that it only has two items. This is bizarre. Any
thoughts?
Code fragment may be found below. Thanks, Alan
while (inFile >> sensed_data.time >> sensed_data.sensor_who >>
sensed_data.aircraft_who {
// cout << "Reading input file\n";
if (sensed_data.time == last_clock)
{
cout << "Adding report to list\n";
cout << "Data to add: " << sensed_data.sensor_who << " "
<< sensed_data.aircraft_who << "\n";
sensor_reports.push_back (sensed_data);
cout << "# sensor reports = " << sensor_reports.size() <<
"\n";
}