Hi all, I am trying to reading stuffs from the text file, i don't know y but program can't read off the tab space

eg.
it reads

Hi HappyDay 325

but it can't read

Hi      Happy Day           325

like where we used more than one spacing for one word or tab spacing

here is my code plz help me

void get_graph(string const &filename, NodeMap &node_map) 
{

    ifstream inf(filename.c_str());
    string from, to;
    double weight;
    while(inf.good()) 
    {
        inf >> from >> to >> weight;
        if ( inf.good() ) 
        {
            Node *Target = node_map.find_in_nodemap(to);
            Node *Source = node_map.find_in_nodemap(from);
            Edge *connector = new Edge(weight,Target);
            Source->neighbors.push_back(connector);
        }
    }
}
int main()
{
    NodeMap nodes;
    ifstream inf;
    string filename;
    cout<<"Enter filename : ";
    cin>>filename;
    inf.open(filename.c_str());
        get_graph(filename, nodes);
        .
        .
        .
}
Member Avatar for jencas

inf >> from >> to >> weight;

reads

Hi -> from
Happy -> to
Day -> weight

What you can do:
1) mark Happy Day as one word
Hi "Happy Day" 325
2) read with getline and parse the line appropriately

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.