• TestingDocs
TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C Tutorials

C scanf Function

Overview

The C scanf function is a standard library function. The Standard Input/Output Library contains functions for formatted data transfer in and out of the C program. The two such functions are as follows:

  • printf (print formatted) function
  • scanf (scan formatted) function

The data printing and reading functions are defined as standard functions which are part of
the language specification but are not part of the C Language itself. The functions are defined in the system header file stdio.h

scanf Function

The C scanf function is a standard library function to read data from the standard input. This function is the counterpart of the printf function.

The scanf() function reads input from stdin, according to the given format, and stores the data in the other arguments.

Syntax

The general syntax of the scanf function is:

scanf(format, arg1,arg2,…);

The format string contains the conversion specifications. The arguments should be pointers to indicate where the input should be stored.

Examples

Read an Integer

To read an integer and store it into an integer variable called a number.

scanf(“%d”,&number);

The & is the ‘address of‘ operator in the C language. The &number returns the address of the variable number.

Read float Number

In this example, we will use the scanf function to read data into float variable length.

scanf(“%f”,&length);

C scanf Function

Related Posts

C Language Characteristics

C Tutorials /

C Language Characteristics

C Source Code .c File

C Tutorials /

C Program Files & Formats

GNU Compiler Collection GCC

C Tutorials /

C Compilers

C Pointers

C Tutorials /

C Pointers

C Tutorials /

C Two-Dimensional Arrays

‹ C for loop statement› C Programming Cycle

Recent Posts

  • How to secure your SQL Database: Tips and Tricks
  • Shaping the Future of Development: Exploring Key Trends in Software Engineering
  • Improving Java Performance with Multithreading
  • Difference between PHP and JavaScript?
  • Bing Conversation Styles
  • ChatGPT Introduction
  • Open Source AI Frameworks
  • Artificial Intelligence Tools
  • Top AI Music Applications
  • Top AI Website Design Tools

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com