O'Reilly logo

C Programming Absolute Beginner’s Guide, Third Edition by Dean Miller, Greg Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8. Interacting with Users

In This Chapter

Looking at scanf()

Prompting for scanf()

Solving problems with scanf()

printf() sends data to the screen. The scanf() function gets data from the keyboard. You must have a way to get data from your user. You can’t always assign data values using assignment statements. For example, if you were writing a movie theater program for use throughout the country, you couldn’t assign the cost of a ticket to a variable using the equals sign in your program because every theater’s ticket price could differ. Instead, you would have to ask the user of the program in each theater location how much a ticket costs before computing a charge.

At first glance, the scanf() function might seem confusing, but it is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required