Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>cscanf() read formatted data from console</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 cscanf()                Read Formatted Data from Console

 #include <conio.h>

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

    cscanf() reads from the console and stores the data read in the
    locations specified by 'argument'.  getche() is used to read the
    characters.

    The format string and arguments for cscanf() are the same as those
    for scanf().  See the description of the scanf() function for a
    detailed explanation of the format string and arguments.


       Returns:     The number of fields that were successfully converted
                    and assigned; a field that was read but not assigned
                    is not counted in the return value.  A return value
                    of EOF means an attempt was made to read at the end-
                    of-file. A return value of 0 means no field were
                    assigned.

   -------------------------------- Example ---------------------------------

    The following statements print a prompt, wait for input in the form
    of two strings, and verify the input by printing out the contents of
    the strings.

           #include <conio.h>

           int result;
           char buffer1[15], buffer2[15];

           main()
           {
               cprintf("Enter your name:");
               result = cscanf("%15s %15s",buffer1, buffer2);
               cprintf("\nEntered: %s, %s\n",buffer2, buffer1);
           }


See Also: fscanf() scanf() sscanf() printf()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson