8. Interacting with Users
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 ...
Get C Programming Absolute Beginner’s Guide, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.