home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixlib36d
/
src
/
stdio
/
c
/
scanf
< prev
next >
Wrap
Text File
|
1994-03-08
|
1KB
|
68 lines
static char sccs_id[] = "@(#) scanf.c 2.0 " __DATE__ " HJR";
/* scanf.c (c) Copyright 1990 H.Rogers */
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
__STDIOLIB__
int
sscanf (register const char *buf, const char *format,...)
{
va_list ap;
int cnt;
static FILE f[1];
f->i_ptr = f->i_base = (unsigned char *) buf;
f->i_cnt = f->bufsiz = strlen (buf);
f->flag = _IOREAD | _IOFBF | _IOEOF;
f->pos = 0;
f->fd = -1;
va_start (ap, format);
if (__scanf (f, format, ap, &cnt) < 0)
{
va_end (ap);
return (-1);
}
va_end (ap);
return (cnt);
}
int
fscanf (register FILE * f, const char *format,...)
{
va_list ap;
int cnt;
va_start (ap, format);
if (__scanf (f, format, ap, &cnt) < 0)
{
va_end (ap);
return (-1);
}
va_end (ap);
return (cnt);
}
int
scanf (const char *format,...)
{
va_list ap;
int cnt;
va_start (ap, format);
if (__scanf (stdin, format, ap, &cnt) < 0)
{
va_end (ap);
return (-1);
}
va_end (ap);
return (cnt);
}