Question: How to read CSV files into a structure? How to create a C function that read the following csv file example into structs? Format The
How to read CSV files into a structure? How to create a C function that read the following csv file example into structs?
Format The board file is structured as follows. Literal constant values are shown in italics Number of spaces, the number_of_spaces in the file Two blank lines A line for the headers which have the following format Type, Set ID, Intraset Id, Name, Property Cost, House Cost, Hotel Cost, Rent with House, Rent with Hotel The actual spaces of the board Each space is connected to the space next to it with the last space connecting back to the first space There are two types of spaces 1. GO space 2. Property Space GO spaces have the following format GO, amount of money to collect when passing go, Name of Space The GO space will always be the first space in the board Property spaces have the format as described by the header field. Heres what each field means Type: either Go for a GO space or Property for a property space Set ID: Which set this property belongs to. Sets are the same thing as color groups in Monopoly but we are using numbers instead of colors. Set Ids start at 0 and increase sequentially Intraset Id: The position of the property within the set. When printing out properties within a set the intraset id is used to figure out what order the properties should be printed. Properties within a set are shown in ascending order based on their intraset id Intraset ids begin at 0 and increase sequentially within the set Name: The name of the property Property Cost: How much it costs to purchase the property House Cost: How much it costs to purchase a house on this property once you own all the properties within the set Hotel Cost: How much it costs to upgrade a group of houses to a hotel Rent with House: How much money this property makes when there is a single house on it Rent with Hotel: How much money this property makes when there is a hotel on it Example of a Board File Number of Spaces,10,,,,,,,, ,,,,,,,,, ,,,,,,,,, Type,Set Id,Intraset Id,Name,Property Cost,House Cost,Hotel Cost,Rent,Rent with House,Rent With Hotel Go,400,MU,,,,,,, Property,0,0,Kemper A,500,50,50,5,50,2000 Property,0,1,Kemper B,1000,50,50,10,75,2500 Property,1,0,Bainer A,2000,200,200,20,100,3000 Property,1,1,Bainer B,2500,200,200,25,150,3000 Property,1,2,Bainer C,3000,200,200,30,200,3500 Property,2,0,SocialSci A,4000,400,400,40,300,4000 Property,2,1,SocialSci B,4500,400,400,45,400,4000 Property,2,2,SocialSci C,5000,400,400,50,500,4000 Property,2,3,SocialSci D,5500,400,400,55,600,4500
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
