Special offer for new customers: 5% OFF your first order! Use coupon: GWRITERSclose

Simple code

. [prob1.c][100%] Develop a C program to read hurricane data and store and sort those hurricane data.
Each hurricane record contains the hurricanes name, year, month, and category. An input file named
hurricane.txt contains 100 hurricane records. Your program will perform the following tasks.
a) Read hurricane data from input file hurricane.txt and store them in an array of structure. The
structure definition is shown below. Then write the hurricane data stored in the array of structure
to a binary file named hurricane.bin.
typedef struct hurricane
{
char name[20];
int year;
int month;
int category;
}H_RECORD;
b) Create a new structure for storing the same hurricane data. This new structure should contain the
same members (name, year, month, and category) but utilize a minimum size as a data type.
Take the definition of the new structure shown below as an example. Design this new structure
so that the value sizeof(H_RECORD_MIN) is minimized. Read hurricane data from input file
hurricane.txt, store them in an array of this new structure, and write the hurricane data stored
in the array of new structure to a binary file named hurricane_min.bin.
typedef struct hurricane_min
{

}H_RECORD_MIN;
[Hint: examine the range required for each member and modify their data type/size.]
c) Display on the screen the file sizes of hurricane.txt, hurricane.bin, and hurricane_min.bin.
[Hint: you can use fseek() and ftell().]
d) Read hurricane from input file hurricane.txt, store them in an array of structure, sort the
hurricane data by its category from minimum to maximum, and write the sorted hurricane data to
a text file named hurricane_sort.txt. In the output file hurricane_sort.txt, category-1
hurricanes will appear first, then category-2 hurricanes, category-3 hurricanes, and so on.
A template source code is provided. In the template, the main() function first calls Setup() to
generate the input file named hurricane.txt. Then the main() function calls DisplayMax()
that displays on the screen all hurricanes of maximum category. Then the main() function calls the
following four functions (in order):
SaveBinFile() performing task a), generating hurricane.bin
SaveBinFileMin() performing task b), generating hurricane_min.bin
DisplayFileSize() performing task c), accessing hurricane.txt, hurricane.bin,
hurricane_min.bin
SaveSortTxt() performing task d), generating hurricane_sort.txt
The template compiles correctly with warnings of unused variables, which should disappear once
you use those variables in your code. The flow of the program and the input and output file names
are all set up properly. DisplayMax() provides an example of reading hurricane records and
storing them in an array of structure. You can complete this program by filling the blanks inside
the function definitions. Only insert your code inside the definitions of aforementioned four
functions. No modifications should be done to any other part of the template source code.
In your report, describe in detail what your functions do and your implementation details. You can also
include your source code in your report in case your source code submission on Blackboard encountered
unexpected difficulties. However, you must submit your source code file (.c), not just Word or PDF
document containing the source code.

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes