INIFile::ReadString

Contents

Description

Reads the value of a key in a given section into a string.

Syntax

string ReadString( LPCSTR lpcszSection, LPCSTR lpcszKey, LPCSTR lpcszDefault = NULL )

Parameters

lpcszSection
[input] section name
lpcszKey
[input] key name
lpcszDefault
[input] to set the default value if not NULL.

Return

the value of a key in a given section in the form of a string

Examples

EX1

void INIFile_ReadString_ex1()
{
    // reads and prints all the key values in all sections
    string str;
    INIFile ini("Origin.ini");
    StringArray saSections, saKeys;
    ini.GetSectionNames(saSections);
    for( int iSection = 0; iSection < saSections.GetSize(); iSection++ )
    {
        printf("%s\n", saSections[iSection]);
        ini.GetKeyNames(saKeys, saSections[iSection]);
        for( int iKey = 0; iKey < saKeys.GetSize(); iKey++ )
        {
            str = ini.ReadString(saSections[iSection], saKeys[iKey]);
            printf("    %s = %s\n", saKeys[iKey], str);
        }
    }
}

Remark

See Also

INIFile::ReadDouble

header to Include

origin.h