2.1.6.8 convert_double_vector_to_string_vector


Description

Convert double vector to string vector.

Syntax

int convert_double_vector_to_string_vector( const vector<double> & vd, vector<string> & vs, uint nSize, vector<string> & vsFormat = NULL )

Parameters

vd
[input] source vector to convert
vs
[output] the vector to return string array
nSize
[input] value to set vs's size
vsFormat
[input] convert format for each cell in vd.

Return

Size of converted vector, -1 if convert fail.

Examples

EX1

void convert_double_vector_to_string_vector_ex1()
{
    vector<string> strVec;
    vector<double> dVec = {1.113,0.786,3,-2.097,10.894,2.168,0,8.123};
    vector<string> strFmt = {"*2","*2","*2","*2","*3","*3","*3","*3"}
    int nRet = convert_double_vector_to_string_vector(dVec , strVec ,8, strFmt);
    //output: 8 items converted :1.1   0.79   3.0   -2.1   10.9   2.17   0.00   8.12  
    if(nRet)
    {
        printf("%d items converted :\n" , nRet);
        for(int ii = 0; ii < strVec.GetSize() ; ii++)
            printf("%s   " , strVec[ii]);
        printf("\n");
    } 
    else 
        printf("Convert failed");
}

Remark

See Also

okutil_convert_double_vector_to_string_vector, convert_int_vector_to_string_vector, convert_str_vector_to_num_vector

Header to Include

origin.h

Reference