convert_str_vector_to_num_vector

 

Description

convert a string vector into a double vector. If a string is empty or "--", it will be converted to be NANUM, else will get corresponding numeric value.

Syntax

int convert_str_vector_to_num_vector( const vector<string> & vs, vector<double> & vd )

Parameters

vs
[input] the string vector to be converted.
vd
[output] the double vector for the result.

Return

the number of converted strings.

Examples

EX1

int convert_str_vector_to_num_vector_ex1()
{
    vector<string> vs = {"13.3","412342.234123e5","1234.3","aa"};
    vector<double> vd;
    int iRet=convert_str_vector_to_num_vector(vs,vd);
    for (int ii=0; ii<iRet; ii++)
        printf("%f\n",vd[ii]);
    return 0;
}

Remark

See Also

convert_double_vector_to_string_vector, convert_tree_double_vector_to_str_vector

header to Include

origin.h

Reference