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
issue.

thanks,
Asad

// 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;

                        h_str.read(ver,sizeof(ver));
                        std::cout<<" INBOUND : Version read : " <<ver<<std::endl;
                        h_file.getline(s1,sizeof(s1));
                        std::cout<<s1<<std::endl;

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

                        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;
                        
                        h_file.getline(s1,sizeof(s1));
                
                        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);
    thrd_hb.join();
        thrd_acc.join();
        
        file.close();
        str.close();
        //std::cout<<"kjdshkjf";
}

-- 
View this message in context: http://old.nabble.com/Can-any-one-help-me-with-this-fstream-tp26986763p26986763.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk