Objective
To create an array of an array of structs, the dimensions based on a file. Then store that into a Linked List.
I am reading from a file formatted like this:
Read a file that is in the form:
name (string) country (string) age (int)
john USA 54
Sam Aus 18
ect
I dont know how many rows and columns the file will have , nor do I know what varible type each column will be
So in theory the first array of struct will contain [NUMBER OF COLUMNS] strucs that will store each variable (using a void pointer and typecasting) along the line( so strucArrayCol[0] = john , structArrayCol[1] = USA ect).
Each of these array of strucs will be stored into another array of strucs which will have [NUMBER OF ROWS] elements so strucArray2Row[0] = strucArrayCol (which contains john , USA and 54) and strucArrayRow[1] will contain another strucArrayCol which contains (sam Aus 18).
So right now I can read the file, and find the number or rows, columns and the variable type of each column.
This is where i start having trouble as im not sure how to go about
1. How to create this array within array ( I know i need to use Malloc)
2.How I would store the variables in the first array of struc, if I
wanted to store age could I just do
void *data = malloc(sizeof(int));
*((int*)data) = TEMP_AGE;
void data being a struc in StrucArrayCol ( in the case of the example if I wanted to store the age of John void* data would be in StrucArrayCol[3] which is inside StucArrayRow[0], as its the 3rd col in the first line)
Sorry if this dosent make sense Thanks