Click or drag to resize

VScanf

Reads formatted input from a device.

virtual HRESULT VScanf(const CString strFormat, va_list& argList, long lTimeout = CUR_TIMEOUT) abstract;	
Parameters
strFormat

[in] String describing the format for arguments. See the topic I/O Format Specifiers for Write Operations for details.

argList

[in] Argument list interpreted by the format string.

lTimeout

[in] I/O timeout in milliseconds.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

This function behaves identically to Scanf except that the arguments are supplied using a va_list argument list instead of separate argument parameters. This type of argument list function is typically used to implement higher-level functions that accept variable argument lists. Indeed, the implementation of Scanf in NtlIo.inl is done in terms of VScanf, as shown in the example later.

The lTimeout parameter allows the I/O timeout to be temporarily changed to the specified value for the duration of the VScanf function call. The timeout is returned to its previous value after VScanf returns. If lTimeout is not specified, then the I/O timeout is not modified.

Example

The following example demonstrates use of the VScanf function.

C++
// NtlIo.inl
inline HRESULT CIoSession::Scanf(const CString strFormat, ...)
{
    if (!Initialized()) return m_pErrReporter->NotInitialized();

    HRESULT hr = S_OK;

    va_list argList;
    va_start(argList, strFormat);

    hr = CFormattedIo::VScanf(m_spBuf, m_pEnumFormatter, strFormat, argList);

    va_end(argList);

    if (SUCCEEDED(hr))
    {
        hr = PollInstrumentErrors();
    }

    return hr;
}
See Also

Download a complete CHM version of this documentation here.