Robotics scanf and strings March 18 th, 2011
Today’s learning objective Use character strings Use the “scanf” function to input data into C programs. Make our own madlib programs!
Here’s the story… It was a _________ day at PATH. Mr. Oakland was ___________ because someone had _________ the _________.
character strings We’ve met “int” before. This is a variable of type integer. “char” means a character. What do you suppose the last line means? int mynumber; char mycharacter; char mystring[80];
When the program sees a scanf statement, it will stop and wait for the user to type something, and then try to put the user's input into the variable scanf ("%s", &string1);.
Classwork 1 Go to Download, compile, and run “madlib.c”
Classwork 2 Modify the “madlib.c” program to make a different story. You might want to change the types of strings the computer asks for. For example, ask for someone’s name, or a location. When you are done, show your program to someone else and have them run it without knowing what story it will make!