//
crt_scanf_s.c
// This program uses the scanf_s and wscanf_s functions
// to read formatted input.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
int i,
result;
float fp;
char c,
s[ 80 ];
wchar_t wc,
ws[ 80 ];
result = scanf_s( " %d %f %c %C %s %S " , &i, &fp, &c, 1 ,
&wc, 1 , s, _countof(s), ws, _countof(ws) );
printf( " The number of fields input is %d\n " , result );
printf( " The contents are: %d %f %c %C %s %S\n " , i, fp, c,
wc, s, ws);
result = wscanf_s( L " %d %f %hc %lc %S %ls " , &i, &fp, &c, 2 ,
&wc, 1 , s, _countof(s), ws, _countof(ws) );
wprintf( L " The number of fields input is %d\n " , result );
wprintf( L " The contents are: %d %f %C %c %hs %s\n " , i, fp,
c, wc, s, ws);
}
// This program uses the scanf_s and wscanf_s functions
// to read formatted input.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
int i,
result;
float fp;
char c,
s[ 80 ];
wchar_t wc,
ws[ 80 ];
result = scanf_s( " %d %f %c %C %s %S " , &i, &fp, &c, 1 ,
&wc, 1 , s, _countof(s), ws, _countof(ws) );
printf( " The number of fields input is %d\n " , result );
printf( " The contents are: %d %f %c %C %s %S\n " , i, fp, c,
wc, s, ws);
result = wscanf_s( L " %d %f %hc %lc %S %ls " , &i, &fp, &c, 2 ,
&wc, 1 , s, _countof(s), ws, _countof(ws) );
wprintf( L " The number of fields input is %d\n " , result );
wprintf( L " The contents are: %d %f %C %c %hs %s\n " , i, fp,
c, wc, s, ws);
}