Borland C++ reference

cscanf

raw OCR

Scans and formats input from the console.

Defined in header <conio.h>

Syntax

#include <conio.h>
int cscanf(char  *format[,address, ...]);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

cscanf scans a series of input fields one character at a time, reading directly from the console. Then each field is formatted according to a

See scant for details

format specifier passed to cscanf in the format string pointed to by format.

on format specifiers.

Finally, cscanf stores the formattedat an address passed to it as
inputan

argument following/ormflf, and echoes the input directly to the screen. There must be the same number of format specifiers and addresses as there are input fields.

cscanf 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 scanf for a discussion of possible causes.

Return value

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

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

See also

Example

#include <conio.h>              \

int main(void)
{
   char string[80];

   clrscrO;                    /* clear the screen */
   cprintf("Enter a string:"); /* prompt the user for input */
   cscanf("%s", string);       /* read the input */

   /* display what was read */
   cprintf("\r\nThe string entered is: %s", string);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.