Wikia

Programmer's Wiki

Scanf

Talk2
385pages on
this wiki

Scanf is a function that reads input data in text based console programs.  It is declared in stdio.h.

Contents

Syntax Edit

int scanf( 
  const char *format [,
  argument]...


Parameters Edit

Format - Format of the incoming data

Argument - Optional variable outputs


Usage Edit

This function will be used when input is required in console programs when using stdio.  This will receive all input on the line until the enter key is pressed.  It will then place the value into the variables you have declared.  This is an example:

include<stdio.h>

int main()
{
char c;
    printf("Enter a letter");
    scanf("%d",c);
    if(c == 'e')
      //do something
}

Note Edit

This function is sometimes unsafe because it takes the input and places it into the variable defined.  This can cause buffer overload unless you use a width for the format, or use scanf_s

Advertisement | Your ad here

Photos

Add a Photo
28photos on this wiki
See all photos >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki