Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

_snscanf, _snwscanf

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,


The input string to examine.
The number of characters to examine in input.
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.


See sscanf for more information.

Generic-Text Routine Mappings

TCHAR.H routine _UNICODE & _MBCS not defined _MBCS defined _UNICODE defined
_sntscanf _snscanf _snscanf _snwscanf


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.


All versions of the C run-time libraries.


// 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);


_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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.