_snscanf, _snwscanf
Visual Studio .NET 2003
Read formatted data of a specified length from a string.
int __cdecl _snscanf( const char * input, size_t length, const char * format, ... ); int __cdecl _snwscanf( const wchar_t * input, size_t length, const wchar_t * format, ... );
Parameters
- input
- The input string to examine.
- length
- The number of characters to examine in input.
- format
- One or more format specifiers.
- ... (optional)
- Strings that will hold the text specified by each format specifier (format).
Return Value
See sscanf for more information.
Remarks
See sscanf for more information.
Generic-Text Routine Mappings
| TCHAR.H routine | _UNICODE & _MBCS not defined | _MBCS defined | _UNICODE defined |
|---|---|---|---|
| _sntscanf | _snscanf | _snscanf | _snwscanf |
Requirements
| Routine | Required header | Compatibility |
|---|---|---|
| snscanf | <stdio.h> | Win 98, Win Me, Win NT, Win 2000, Win XP |
| snwscanf | <stdio.h> or <wchar.h> | Win 98, Win Me, Win NT, Win 2000, Win XP |
For additional compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
Example
// crt_snscanf.c
#include <stdio.h>
int main( )
{
char str1[] = "15 12 14...";
wchar_t str2[] = L"15 12 14...";
char s1[81];
wchar_t s2[81];
int i;
float fp;
i = _snscanf( str1, 6, "%s %f", s1, &fp);
printf("_snscanf converted %d fields: ", i);
printf("%s and %f\n", s1, fp);
i = _snwscanf( str2, 6, L"%s %f", s2, &fp);
wprintf(L"_snwscanf converted %d fields: ", i);
wprintf(L"%s and %f\n", s2, fp);
}
Output
_snscanf converted 2 fields: 15 and 12.000000 _snwscanf converted 2 fields: 15 and 12.000000
See Also
scanf Width Specification | Run-Time Routines and .NET Framework Equivalents