Thanks for your help earlier with the file input everyone...I have another question to ask of you. I am trying to check two vectors against each other to see if the "timeanddate" match up. Then try to output the ones that do match. I am getting errors from the if statement down, as the inputting works flawlessly. Any help would be great! Thanks in advance.
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std ;
struct Weather
{
string timeanddate;
double wind;
double windmax;
};
struct Weather2 {
string timeanddate;
string excel;
string date;
string time;
int windr;
double wind;
double windmps;
};
struct Golf {
string timeanddate;
double wind_obs;
double wind_sensor;
};
int main()
{
int a =0, i,j;
string DataStream1;
string DataStream2;
string DataStream3;
vector<Weather> Sensor;
vector<Weather2> Observations;
vector <Golf> Search;
Golf Foundb;
ifstream DataFile1("Wind Sensor Data.txt");
while(getline(DataFile1, DataStream1))
{
istringstream Incoming(DataStream1);
Weather w;
Incoming >> w.timeanddate >> w.wind >> w.windmax;
Sensor.push_back(w);
}
ifstream DataFile2("Wind Observation.txt");
while(getline(DataFile2, DataStream2))
{
istringstream Incoming(DataStream2);
Weather2 x;
Incoming >> x.timeanddate >> x.excel >> x.date >> x.time >> x.windr >> x.wind >> x.windmps;
Observations.push_back(x);
}
\\HERE BEGINS THE PROBLEM...
for(i= 0; i <= Sensor.size(); i++) {
for (j=0; j <=Observations.size(); j++) {
if (Sensor[i].timeanddate==Observations[j].timeanddate) {
Foundb.timeanddate = Sensor[i].timeanddate;
Foundb.wind_obs = Observations[j].wind;
Foundb.wind_sensor = Sensor[i].wind;
Search.push_back(Foundb);
}
}
}
ofstream DataFile3("C:\Documents and Settings\ttrusse\Desktop\Algeciras\Matchup.txt");
for (a=0; a<=Search.size(); a++) {
ostringstream Outgoing(DataStream3);
Outgoing << Search[a].timeanddate << Search[a].wind_obs <<Search[a].wind_sensor<<endl;
}
return 0;
}
Debug Window Shows...
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
First-chance exception in sensor.exe: 0xC0000005: Access Violation.