sscanf_s, swscanf_s

From RAD Studio
Jump to: navigation, search

Go Up to stdio.h Index


Header File

stdio.h

Category

Formatted input/output functions

Syntax

int sscanf_s(const char * restrict s, const char * restrict format, [,address,...]);

int swscanf_s(const wchar_t * restrict s, const wchar_t * restrict format, [,address,...]);

Description

Replaces sscanf adding security enhancements.

sscanf_s is equivalent to fscanf_s, fwscanf_s except the input is a string rather than a stream. The end of the string is equivalent to end-of-file for fscanf_s.

Return Value

On success, sscanf returns the number of input fields successfully scanned, converted, and stored; the return value does not include scanned fields that were not stored. The return value can be zero in case there is a matching error on the first argument.

If an error occurs before any conversion is done, it returns EOF.

Example

#include <stdio.h>
#include <stdlib.h>
int main(void)
{
 int x;
 char c;
 char buffer[80]="4 a";
 sscanf(buffer, "%d %c", &x, &c);
 printf_s("%d %c", x, c);   
 return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

sscanf_s

+

+

+

+

swscanf_s

+

+

+

See Also