file::WriteInt

Description

Write a set of Integer data into file

Syntax

UINT WriteInt( void * pSrcBuffer, int nDataTypeSize, UINT nItemCount, BOOL bIsLittleEndian = TRUE )

Parameters

pSrcBuffer
[input] Destination's buffer of store the int value
nDataTypeSize
[input] Must be size of datatype. for integer, 1, 2 and 4. for float, 4 and 8.
nItemCount
[input] Number of data;
bIsLittleEndian
[input] TRUE, use Little Endian way, FALSE use Big Endian way, default value is TRUE.

Return

The number of items write to file.

Examples

EX1

void file_WriteInt_ex1()
{
    file ff("C:\\int.txt", file::modeCreate | file::modeWrite);
    vector<int> v(5);
    for ( int ii = 0; ii < v.GetSize(); ii++ )
        v[ii] = ii;
    
    ff.WriteInt(v, sizeof(int), v.GetSize());
    ff.Close();
    
    file fr("C:\\int.txt", file::modeRead);
    vector<int> ve(5);
    fr.ReadInt(ve, sizeof(int), ve.GetSize());
    fr.Close();
    //v and ve should contains same data.
}

Remark

See Also

file::ReadInt

header to Include

origin.h