Click or drag to resize

Scanf

Reads formatted input from a device.

virtual HRESULT Scanf(const CString strFormat [, argument] ...) abstract;
Parameters
strFormat

[in] String describing the format of the data to be read. See the topic I/O Format Specifiers for Read Operations for details.

argument

[in] Optional arguments interpreted by the format string.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

The Scanf function reads and formats data using the strFormat format specifier. The scanned data is stored in the argument passed to Scanf.

Example

The following example demonstrates use of the Printf function. Note that the topic I/O Format Specifiers for Write Operations has many more examples of format strings that can be used with Printf.

C++
// CoAcme4321.cpp
STDMETHODIMP Acme4321::IAcme4321_Configure()
{
  HRESULT hr = S_OK;

  // Send ID query to device
  hr = io.PrintfNoPoll(_T("*IDN?"));
  if (SUCCEEDED(hr))
  {
    CString strManufacturer, strModel, strSerial, strRevision;

    hr = io.Scanf(_T("%$C[^,],%$C[^,],%$C[^,],%$C[^,]"), &strManufacturer, &strModel, &strSerial, &strRevision);           
  }

  return hr;
}
See Also

Download a complete CHM version of this documentation here.