Borland C++ reference

vfscanf

raw OCR

Scans and formats input from a stream.

Defined in header <stdio.h>

Syntax

#include <stdio.h>
int vfscanf(FILE *stream, const char *format, vajist arglist);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

Available on UNIX System V.

The v...scanf functions are known as alternate entry points for the ...scant functions. They behave exactly like their ...scant counterparts, but they accept a pointer to a list of arguments instead of an argument list.

See scant for details

vtscanf scans a series of input fields, one character at a time,

on format specifiers.

from a stream. Then each field is formattedto
reading format specifier passed to vfscanf in the format string pointed to by format. Finally, vfscanf stores the formatted input at an address passed to it as an argument following/ormaf. There must be the same number of format specifiers and addresses as there are input fields.according a

vfscanf might stop scanning a particular field before it reaches the normal end-of-field (whitespace) character, or it might terminate entirely, for a number of reasons. See scant for a discussion of possible causes.

Return value

vtscanf returns the number of input fields successfully scanned, converted, and stored; the return value does not include scanned fields that were not stored. If no fields were stored, the return value is 0.

If vtscanf attempts to read at end-of-file, the return value is EOF.

See also

Example

#include <stdio.h>
#include <stdlib.h>

FILE *fp;
int vfsf (char *fmt, ...)
{
   va_list  argptr;
   int cnt;
   va_start (argptr, fmt);
   cnt = vfscanf (fp, fmt, argptr);
   va_end (argptr);
   return (cnt);
}
int main (void)
{
   int inumber  = 30;
   float fnumber  = 90.0;
   char string [4] = "abc";
   fp = tmpfileO  ;
   if  (fp == NULL) {
      perror( "tmpfileO  call");
      exit(l);
   }
   fprintf (fp,"%d %f %s\n",inumber,fnumber, string)
   rewind (fp);
   vfsf("%d  %f %s",&inumber,&fnumber, string);
   printf("%d  %f %s\n",inumber,fnumber, string);
   fclose (fp);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.