[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


sscanf

Read formatted text into a character string.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdio.h>
int sscanf(char *s, const char *format, ...);
Parameters:

Parameters for this facility are:

s  
char *  
The string to be scanned  
format  
const char *  
The format string  

Remarks:

The sscanf() operates identically to scanf() but reads its input from the character array pointed to by s instead of stdin. The character array pointed to s must be null terminated.

For specifications concerning the input control string and conversion specifications see: "Input Control String and Conversion Specifiers." Also see "Scanset," for a full description of the use of scansets.

Return:

scanf() returns the number of items successfully read and converted and returns EOF if it reaches the end of the string or a conversion specification does not match its argument.

See Also:

"Wide Character and Byte Character Stream Orientation"

"fscanf"

"scanf"

Example of sscanf() usage.:
#include <stdio.h>

int main(void)
{
	static char in[] = "figs cat pear 394 road 16!";
	char s1[20], s2[20], s3[20];
	int i;

	// get the words figs, cat, road, 
	// and the integer 16
	// from in and store them in s1, s2, s3, and i,
	// respectively
	sscanf(in, "%s %s pear 394 %s %d!", s1, s2, s3, &i);
	printf("%s %s %s %d\n", s1, s2, s3, i);

	return 0;
}

Output:
figs cat road 16


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000