Lesson 3 of 23
Reading Input with scanf()
8 min 20 XP
scanf() reads values from the user. Put & (address-of) before the variable name so scanf can write into it. Use %lf to read a double.
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.Reading a string (char array) needs no &, because an array's name is already an address. %s reads only one word, up to a space.