Header File
conio.h
Category
Console I/O Routines
Prototype
int cscanf(char *format[, address, ...]);
Description
Scans and formats input from the console.
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 format specifier passed to cscanf in the format string pointed to by format. Finally, cscanf stores the formatted input at an address passed to it as an argument following format, 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 returns the number of input fields successfully scanned, converted, and stored; the return value does not include scanned fields that were 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.
Example
#include <conio.h> int main(void) { char string[80]; /* clear the screen */ clrscr(); /* Prompt the user for input */ cprintf("Enter a string with no spaces:"); /* read the input */ cscanf("%s", string); /* display what was read */ cprintf("\r\nThe string entered is: %s", string); return 0; }
Portability
POSIX |
Win32 |
ANSI C |
ANSI C++ |
|
+ |
|
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|