A function in the C programming language used in text mode applications to read input from stdin.

unsigned int scanf(data type, void *)

example of usage:

int main() {
int myNumber;
printf("Please enter a number: ");
scanf("%d", &myNumber);

scanf() returns the number of ints (in this case) received by stdin and store the entered number at the memory address of myNumber.

#include <stdio.h>

int scanf( char* string, ... );

This function reads formatted input from stdio. The data is converted and stored at addresses given by the arguments that follow string. These arguments should also contain format specifications for the data read. If the end of the file is reached before any conversion takes place, scanf() will return EOF. If successful, it will return the number of items read and stored.

See also: fscanf().

Back to Essential C Functions.

Log in or register to write something here or to contact authors.