$24
I have provided an unchangeable cscd240Lab13.c file. Your task is to write the functions.
The structure will contain:
char *street;
char *city;
char *state;
int zip;
The menu portion will contain:
Print the array sorted by street
Print the array sorted by city
Print the array sorted by state then city then by zip
Print the array sorted by zip
Quit
You must verify range for the menu.
The input will come from a file, name entered by the user. I have provided all the code for opening the file.
The sorts, stated above, come from calling qsort passing as the 4th parameter the function pointer to the proper compare function. You will need to write the compare functions – NOTE: the compare functions are each passed two Address objects as const void *.
There is no hidden agenda, just trying to get you to work with structures that contain pointers, and function pointers.
To Turn In
Submit a zip file of the Lab13 folder
Containing your C files and H file(s). My Makefile
Containing an output capture from running your program named cscd240Lab13out.txt.
Containing a valgrind run to ensure you are not leaking memory named cscd240Lab13val.txt
Your zip named your last name first letter of your first name lab13.zip (Example: steinerslab13.zip)
Note: For the sample run below, I shortened the menu prompts. Your prompts will not be this short
Please enter the name of the input file input.txt
1 - 5 (5 to Quit) 1
Anywhere Spokane WA 99223
2910 Sudlow
Glendive MT 59301
Caravan Billings MT 59105
318 NW St
Washington DC 10280
319F CEB
Cheney WA 99004
500 Sprague Ave
Spokane WA 99201
6405 Colton
Billings MT 59106
1 - 5 (5 to Quit) 2
Caravan Billings MT 59105
6405 Colton
Billings MT 59106
319F CEB
Cheney WA 99004
2910 Sudlow
Glendive MT 59301
Anywhere Spokane WA 99223
500 Sprague Ave
Spokane WA 99201
318 NW St
Washington DC 10280
1 - 5 (5 to Quit) 3
318 NW St
Washington DC 10280
Caravan Billings MT 59105
6405 Colton
Billings MT 59106
2910 Sudlow
Glendive MT 59301
319F CEB
Cheney WA 99004
500 Sprague Ave
Spokane WA 99201
Anywhere Spokane WA 99223
1 - 5 (5 to Quit) 4
318 NW St
Washington DC 10280
Caravan Billings MT 59105
6405 Colton
Billings MT 59106
2910 Sudlow
Glendive MT 59301
319F CEB
Cheney WA 99004
500 Sprague Ave
Spokane WA 99201
Anywhere Spokane WA 99223
ssteiner@cscd-linux01:~/cscd240s13/Lab13$
==1904== HEAP SUMMARY:
==1904== in use at exit: 0 bytes in 0 blocks
==1904== total heap usage: 23 allocs, 23 frees, 958 bytes allocated
==1904==
==1904== All heap blocks were freed -- no leaks are possible ==1904==
==1904== For counts of detected and suppressed errors, rerun with: -v
==1904== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
ssteiner@cscd-linux01:~/cscd240s13/Lab13$