atof and vector subscripts problems

Hi,

I'm having 2 problems with the following function:

1
2
3
4
5
6
7
8
9
10
void readData( vector< vector<double> > &Vector )
{
    while ( getline( inFile, line ) )                   /
    {
        cout << line << endl;
        position = line.find_first_of( "/ :," );        // Find the position
        rows++;
        cout << endl << endl;
    }
}


It gives the following errors, which I can't figure out:

main.cpp|88|error C2664: 'atof' : cannot convert parameter 1 from 'std::string' to 'const char *'|


I am wanting to convert Value from string (eg. 30.9) to double, then store this in Vector. Where is the problem?

Thanks :)


Last edited on
atof gets a const char* and you are passing a string.
Use string::c_str : atof( entryString.c_str() )

you have a vector<double> and you have two subscripting operators: Vector[ rows ][ columns ]. Change the declaration of 'Vector' to a 2D vector : vector< vector<double> > &Vector
Thanks Bazzy, it worked :)
Last edited on
Topic archived. No new replies allowed.