### _cscanf -- Read Data from Keyboard

Format

>     #include <conio.h>:
>     int _cscanf(char *format-string, argument-list);

Language Level: Extension
_cscanf reads data directly from the keyboard to the locations given by argument-list, if any are specified. The _cscanf function uses 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 the 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 scanf -- Read Data for a description of the format string.

Note: Although _cscanf normally echoes the input character, it does not do so if the last action was a call to _ungetch.

Return Value
_cscanf 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 the end of the file. A return value of 0 means that no fields were assigned.

Example
This example uses _cscanf to read strings from the screen.

    #include <conio.h>

    int main(void)
    {
       char buffer[24];

       _cprintf("\nPlease enter a filename:\n");
       _cscanf("%23s", buffer);
       _cprintf("\nThe file name you entered was %23s.", buffer);
       return 0;

       /************************************************************
          The output should be similar to:

          Please enter a filename:
                                  file.dat
          The filename you entered was                file.dat.
       ************************************************************/
    }

fscanf -- Read Data from a Stream
_getch - _getche -- Read Character from Keyboard
scanf -- Read Data
sscanf -- Read Data from Buffer
_ungetch -- Push Character Back to Keyboard
<conio.h>