C PROGRAMMING

Reading User Input

Article by:
Date Published:
Last Modified:

Contents

Overview

Reading user input is the process of prompting the user for input, and then receiving this by the software so that actions can be done based on what was typed. This applies more to C programs running on Linux and other terminal-capable architectures, rather than embedded microcontrollers.

Using scanf()

scanf() is one of the most common ways of getting user input from a terminal in Linux.

The simplest example is that which gets an integer displayed by the user and stores it in a variable called input.

1
2
int32_t input;
scanf ("%d", &input);

Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Tags

    comments powered by Disqus