Read formatted text from a character string.
Compatibility:This function is compatible with the following targets:
|
|
#include <stdarg.h>
#include <stdio.h>
int vsscanf(const char * s,  
const char * format, va_list arg);
Parameters for this facility are:
On embedded/ RTOS systems this function only is implemented for stdin, stdout and stderr files.
Return: See Also: Example Of Vsscanf() Usage:#include <stdio.h>
#include <stdarg.h>
int ssc(char *, char *, ...);
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
ssc(in, "%s %s pear 394 %s %d!", s1, s2, s3, &i);
printf("%s %s %s %d\n", s1, s2, s3, i);
return 0;
}
// ssc() scans a character string and inputs
// a variable number of arguments using
// the vsscanf() function
int ssc(char * s, char *format, ...)
{
va_list args;
int retval;
va_start(args, format); // prepare the arguments
retval = vsscanf(s, format, args);
va_end(args); // clean the stack
return retval;
}
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