scanf_s() Function in C
This function is specific to Microsoft compilers. It is the same as scanf, except it does not cause buffer overload. scanf_s() function is more secure than scanf() function as it provides an additional parameter to specify the buffer size that can avoid buffer overflow.
Syntax
int scanf_s(const char *format [argument]...);
Parameters
- stream: Pointer to the File object that identifies the stream.
- format: It is a string that contains the type specifier(s).
- … (ellipsis): It indicates that the function accepts a variable number of arguments.
Note: Here we can specify the buffer size and actually control the limit of the input so that the whole application don’t crash due to memory overflow.
Return Value
- On success, the function returns the number of values read.
- In the case of an input failure, before any data could be successfully read, EOF is returned.
Inbuilt library functions for user Input | sscanf, scanf_s, fscanf_s, sscanf_s
The C Programming Language provides various Inbuilt Library Functions for User Input. In this article, we will learn about sscanf, scanf_s, fscanf_s, sscanf_s Library Functions in C.