Homework 29: Arrays in structs
Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Monday, April 3
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw29and submit using the204subcommand. - This is an electronic homework and you do not need to print out anything to turn in during class.
Assignment
- Required reading: Section 4 (Structs with pointers and arrays)) from the Unit 8 notes.
-
Write a program called
raffle.cthat simulates a raffle lottery. Your program will first read in a series of names and exactly 4 raffle ticket numbers for each name, and then "draw" the winning number (by reading again), and finally print out the name(s) of all winners who have that winning number.Of course, you should create a
structfor each person that contains their name as well as an array of their ticket numbers.Example runs:
roche@ubuntu$./raffleHow many people?3Person 1 name:DavePerson 1 tickets:650 205 592 377Person 2 name:ErinPerson 2 tickets:324 980 769 230Person 3 name:JimPerson 3 tickets:442 230 296 230Winning ticket:592Dave won!roche@ubuntu$./raffleHow many people?2Person 1 name:ErinPerson 1 tickets:324 980 769 230Person 2 name:JimPerson 2 tickets:442 230 296 230Winning ticket:592roche@ubuntu$./raffleHow many people?2Person 1 name:ErinPerson 1 tickets:324 980 769 230Person 2 name:JimPerson 2 tickets:442 230 296 230Winning ticket:230Erin won!Jim won!