Implementation of vsscanf() : C
Hello, I am student of the MCA. I have the knowledge of the C language. I have to submit the assignments periodically whichever the professor suggest me. Today my professor of the C language gave me the assignment on the vsscanf() function. I know about the scanf() function. But I did not know about the vsscanf() function. So, I want to know what is vsscanf() function, How can they be used in the program, and what is the diference between the vsscanf() and scanf() functions. Can anyone know about the vsscanf() function.
Implementation of vsscanf()
I guess you know atleast about Library function. Under control of the argument format, The vsscanf() function scans input from the string formatted by in_string. The format string can be described under the description of the scanf() function. With a variable argument list replaced with arg the vsscanf() function is equivalent to the sscanf() function, which has been initialized using the va_start() macro. End Of File is being reached when the scanning is ended by reaching the end of the input string.
Program : Implementation of vsscanf()
There is the program code of lines that describes you about the vsscanf() function :
#include <stdio.h>
#include <stdarg.h>
void sfind( char *string, char *format, ... )
{
v_lst arglst;
v_strt( aglst, frmt );
vsscanf( string, frmt, arglst );
v_end( arglst );
}
void main()
{
int dy, yr;
char wkdy[10], mh[12];
sfind( "Monday August 18 1987",
"%s %s %d %d",
wkdy, mh, &dy, &yr );
printf( "\n%s, %s %d, %d\n",
wkdy, mh, dy, yr );
}
Re: Implementation of vsscanf() : C
Here, one more example of code of vsscanf() function :
#include <crtdll/errno.h>
#include <stdarg.h>
#include <crtdll/stdio.h>
#include <crtdll/string.h>
#include <crtdll/internal/file.h>
#undef vsscanf
int vsscanf (const char *t,const char *frmt,v_lst arg)
{
FILE F;
if (t == NULL)
{
set_errno (EINVAL);
return -1;
}
memset ((void *) &F, 0, sizeof (F));
F._flag = _IOREAD;
F._ptr = (char *)t;
F._base = (char *)t;
F._bufsiz = strlen(t);
F._cnt = F._bufsiz;
return __vfscanf (&F, frmt, arg);
}