Scanf() function is the console input routine. - C Language Basics

C examples for Language Basics:scanf

Introduction

scanf can read all the built-in data types and automatically convert numbers into the proper internal format.

It is like the reverse of printf( ).

The prototype for scanf( ) is

int scanf(const char *control_string, . . . );

The scanf( ) function returns the number of data items assigned a value.

If an error occurs, scanf( ) returns EOF.

The control_string determines how values are read into the variables pointed to in the argument list.

The control string consists of three classifications of characters:

  • Format specifiers
  • White-space characters
  • Non-white-space characters

Related Tutorials