Boost logo

Boost :

Subject: [boost] Can any one help me with this fstream
From: ch.asad_at_[hidden]
Date: 2010-01-01 12:16:21

Hi i am new to boost. i have written a code. can any one guide me whats the
issue with this code.

It gives an error when I assign the File pointer to a Global poiter.
                        h_file = file;
                        h_str = str;

Can any one guide me whats the issue with this and how cna i solve this


// Accelor-test.cpp : Defines the entry point for the console application.
#include <iostream>
#include <string>
#include <fstream>
#include <string>
#include <vector>
#include <iostream>
#include <iterator>
#include <functional>
#include <boost/asio.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/find_iterator.hpp>
#include <boost/thread/thread.hpp>

using boost::asio::ip::tcp;
using namespace std;
using namespace boost;

std::fstream h_file;
int hb;
int cnt;
tcp::iostream h_str;

//boost::mutex mutex;
void Accelor_test()
                        std::cout<<"\nAPP started ...\n";
                        char ver[100];
                        char s1[100];
                        vector<std::string> strng,st,u_p;
                        //int ef;

                        std::cout<<" INBOUND : Version read : " <<ver<<std::endl;

void send_HB()
                std::cout<<"\nHeart Beat Started...";
  // boost::mutex::scoped_lock lock(mutex);
                char h_b[] = "HB\n";
                        boost::xtime xt;
                        boost::xtime_get(&xt, boost::TIME_UTC);
                        xt.sec += 1;

                        std::cout <<"OUTBOUND : HB ,"<< ++cnt << std::endl;

int main(int argc, char* argv[])
                        std::fstream file = std::fstream("inttest_sample.csv",std::fstream::in);
                        if(h_file == NULL)
                                std::cout<<"File not found";

                        char s1[100];
                        vector<std::string> conf,connection,u_p;
                        int ef;
                        std::cout<<"s1 = "<<s1<<endl;
                        std::cout<<"Split Conf";
                        split(conf, s1, is_any_of(","), token_compress_on);
                        split(connection, conf[0], is_any_of(":"), token_compress_on);
                        tcp::iostream str(connection[0],connection[1]);

                        h_file = file;
                        h_str = str;


        boost::thread thrd_hb(&send_HB);
        boost::thread thrd_acc(&Accelor_test);

View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at