Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cscanf(DOS) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     Name
          cscanf - Reads data from the console.

     Syntax
          #include <conio.h>

          int cscanf(format-string[, argument...])
          char *format-string;


     Description
          The cscanf function reads data directly from the console
          into the locations given by the arguments (if any), using
          the getche function to read characters. Each argument must
          be a pointer to a variable with a type that corresponds to a
          type specifier in format-string. The format-string controls
          the interpretation of the input fields and has the same form
          and function as the format-string argument for the scanf
          function; see the scanf reference page for a description of
          format-string.

     Notes
          While cscanf normally echoes the input character, it will
          not do so if the last call was to ungetch.

     Return Value
          The cscanf function returns the number of fields that were
          successfully converted and assigned. The return value does
          not include fields that were read but not assigned.

          The return value is EOF for an attempt to read at end-of-
          file. A return value of 0 means that no fields were
          assigned.

     See Also
          cprintf(DOS), fscanf(S), scanf(S), sscanf(S)

     Example
          #include <conio.h>

          int result; char buffer[20];

          main( )
           {
                  cprintf("Please enter file name: ");

                  /* Read in user response and    *
                  ** return # of matches:    */

                  result = cscanf("%19s",buffer);

                  printf("\nNumber of correctly matched ");
                  printf("input items = %d\n", result );

           }

          This program prompts for a file name and uses cscanf to read
          in the corresponding file. Then cscanf returns the number of
          items matched, and the program displays that number.

                                                (printed 6/18/89)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026