Programming Homework Help

Montana State University Bozeman C Programming Lab Report

 

You are to write a program that will read the names of hurricanes that affected Florida, their categories, and their date from the file lab4/hurricanes.csv.

You will write the list sorted by name to a file. Only print the number of the category, not the whole phrase that is in the file for category. For example, the first hurricane info line you print to your file should look like

Agnes     1    19-Jun,1972

REQUIREMENTS

  • Write your program in a file called lab4.c
  • Your output formatting must match the example. Use a tool like diffchecker to compare the content of your output file with the sample output. You do not need to worry about trailing spaces.

HINTS

  • In previous labs, we have used tabs (t) to space our output. For this assignment, you may want to use padding instead. For example, if the character array var held Colorado , printf("%10s", var) would print Colorado , so that the output took up exactly 10 characters. To print Colorado (with the spaces on the right, we could do printf("%-10s", var).
  • Consider structuring your program like so: store each line in an array of strings. Sort it. (Or sort an array of pointers to strings in your original array.) Then use strtok only when you go to print out the lines in sorted order

———————————————————————————————————————————————————

  • comments explaining what your program does
  • indent your code so it is readable
  • compiles successfully with -Wall – no warnings
  • does not use globals
  • successfully reads from file in same directory as your program
  • prints to a file in a pleasing manner and shows all the information
  • uses fgets to read in each line
  • stores each line in an array of strings
  • sorts the array
  • prints only the category number
  • uses at least 2 functions plus main
  • points – matches the sample output formatting exactly