In an example program my professor gave me that reads data from a file about rooms. For example the data file reads:
The last 4 lines are the lines that have to do with the rooms. The first number is the number of windows, the second (after the colon) is the area, and the last is the name of the room. I have to read data in, store the room info in a dynamically allocated array of structs, sort the array by area (from smallest area to largest), and then display the results.
In main, he just has variable declarations and calls these 3 functions:
My question is regarding the sort() function. He uses an insertion sort algorithm, but I thought that you will need to pass the address of the rooms struct to sort()? Because you are changing the values of rooms, rooms, etc., so in order for show_results() to show the sorted results, I would need to pass the address of rooms (&rooms) to sort()? But this works, I just need a little explanation why you don't have to use pointers here. thanks
read_file(&rooms, &price, owner, &num, argc, argv);
show_results(rooms, price, owner, num);