Anyhelp with the ostringstream and datastream line would be appreciated. Can't seem to get the data to actually write to the text file...No data in results.txt, but the file is created by the program when I run it...

ofstream DataFile3("results.txt");
  cout<<"Writing...Please wait...."<<endl;
  for (a=0; a<Search.size(); a++)  {
	 cout<<Search[a].date<<" "<<Search[a].time<<" "<<Search[a].wind_obs<<" "<<Search[a].wind_sensor<<endl;
	 ostringstream Outgoing(DataStream3);
     Outgoing << Search[a].date << Search[a].time << Search[a].wind_obs <<Search[a].wind_sensor<<endl;

I don't see you writing to DataFile3 in that snippet.

How can I make it output to DataFile3? Thanks!

How about changing this:

Outgoing << Search[a].date << Search[a].time << Search[a].wind_obs <<Search[a].wind_sensor<<endl;

To this:

DataFile3<< Search[a].date << Search[a].time << Search[a].wind_obs <<Search[a].wind_sensor<<endl;

I really can't hold your hand on this because the amount of code you've given is painfully small. I'm really just guessing here. If you want more help, or if my suggestion doesn't work, post more code.

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>

using namespace std ;

struct Weather
{
    string date;
	string time;
    double wind;
};

struct Weather2 {
	string date;
	string time;
	double wind_obs;
	double wind_sensor;
};

int main()
{
  int a =0, i=0,j=0;
  string DataStream1;
  string DataStream2;
  string DataStream3;
  vector<Weather> Sensor;
  vector<Weather> Observations;
  vector <Weather2> Search;
  Weather2 Found;

  cout<<"Pulling in data...Please wait...."<<endl;
  ifstream DataFile1("Wind Sensor Data.txt");
  while(getline(DataFile1, DataStream1))
  {
      istringstream Incoming(DataStream1);
      Weather w;
      Incoming >> w.date >> w.time  >> w.wind;
      Sensor.push_back(w);
  }
  
  ifstream DataFile2("Wind Observation.txt");
  while(getline(DataFile2, DataStream2))
  {
      istringstream Incoming(DataStream2);
      Weather x;
      Incoming >> x.date >> x.time >> x.wind;
	  Observations.push_back(x);
  }
  cout<<"Checking data...Please wait...."<<endl;
  for(i= 0; i < Sensor.size(); i++) {
	  for (j=0; j <Observations.size(); j++) {
		  if ((Sensor[i].date==Observations[j].date) && (Sensor[i].time==Observations[j].time)) {
			 Found.date = Sensor[i].date;
			 Found.time = Sensor[i].time;
			 Found.wind_obs = Observations[j].wind;
			 Found.wind_sensor = Sensor[i].wind;
			 Search.push_back(Found);
	      }
		  
	  } 				
  }

  ofstream DataFile3("C:\\Documents and Settings\\ttrusse\\Desktop\\Algeciras\\C++\\results.txt");
  cout<<"Writing...Please wait...."<<endl;
  for (a=0; a<Search.size(); a++)  {
	 cout<<Search[a].date<<" "<<Search[a].time<<" "<<Search[a].wind_obs<<" "<<Search[a].wind_sensor<<endl;
	 ostringstream Outgoing(DataStream3);
     Outgoing << Search[a].date << Search[a].time << Search[a].wind_obs <<Search[a].wind_sensor<<endl;  
  };
 return 0;
 }

On second thought, your code worked...do I still need the ostringstream line? I'm trying to figure out what the istringstream and ostringstream did for me...Thanks.

I'd say you don't need it, but it's not my place to dictate how you write your code. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.