2.1.10.50 okutil_read_text_file_lines


Description

Read file content into string array.

Syntax

int okutil_read_text_file_lines( LPCSTR lpcszPath, StringArray * psa, int nLines )

Parameters

lpcszPath
[input] full path file name
psa
[output] result string array
nLines
[input] number of lines to read, -1 to read all

Return

number of lines read or -1 if file open error

Examples

EX1

void rf(int nLines = 10)
{
    string strPath = GetOriginPath(ORIGIN_PATH_SYSTEM) + "\\Samples\Graphing\\Axes.dat";
    StringArray sf;
    int nn = okutil_read_text_file_lines(strPath, &sf, nLines);
    out_int("num lines = ", nn);
    for(int ii = 0; ii < sf.GetSize(); ii++) {
        printf("%d: %s\n", ii+1, sf[ii]);
    }
}

Remark

See Also

Header to Included

origin.h

Reference