2.2.5.2.11 INIFile::WriteString

Description

Writes a string value for a given keyname in a given section

Syntax

void WriteString( LPCSTR lpcszSection, LPCSTR lpcszKey, LPCSTR lpcszValue )

Parameters

lpcszSection
[input] section name
lpcszKey
[input] key name
lpcszValue
[input] the string that needs to be written

Return

Examples

EX1

void INIFile_WriteString_ex1()
{
    // writes "***" into all the key values in all sections
    string str = "***";
    INIFile ini("EBGIF2.ini", FALSE);
    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++ )
        {
            ini.WriteString(saSections[iSection], saKeys[iKey], str);
            string str1 = ini.ReadString(saSections[iSection], saKeys[iKey], str);
            printf("    %s = %s\n", saKeys[iKey], str1);
        }
    }
}

Remark

See Also

Header to Include

origin.h