scanf_s, wscanf_s
Go Up to stdio.h Index
Header File
stdio.h
Category
Formatted input/output functions
Prototype
int scanf_s(const char * restrict format,[, address, ...]);
int wscanf_s(const wchar_t * restrict format,[, address, ...]);
Description
Replaces scanf, wscanf adding security enhancements.
Note: For Win32 GUI applications, stdin must be redirected.
scanf_s is equivalent to fscanf_s, fwscanf_s with the stdin argument given for stream.
Return Value
On success, scanf_s returns the number of input fields successfully scanned, converted, and stored. Otherwise the function returns the value of the macro EOF.
Example
#include <stdio.h>
int main(void)
{
int x;
printf_s("int: ");
scanf_s("%d", &x);
printf_s("the number is: %d", x);
return 0;
}