daily pastebin goal
5%
SHARE
TWEET

econdata.h

a guest Jan 18th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2. /**
  3.  * OSU CS162-W18
  4.  *
  5.  * Holds structures, constants, and prototypes for this assignment.
  6.  */
  7. #include <cstdlib>
  8. #include <iostream>
  9. #include <fstream>
  10. #include <string>
  11. #include <sstream>
  12.  
  13. /**
  14.  * The state county information.
  15.  */
  16. struct county {
  17.   // The county name
  18.   std::string name;
  19.   // The unemployed rate in 2007
  20.   float unemployed_2007;
  21.   // The unemployed rate in 2015
  22.   float unemployed_2015;
  23.   // The medium income
  24.   int med_income;
  25. };
  26.  
  27. /**
  28.  * The state information.
  29.  */
  30. struct state {
  31.   // The state name
  32.   std::string name;
  33.   // The unemployed rate in 2007
  34.   float unemployed_2007;
  35.   // The unemployed rate in 2015
  36.   float unemployed_2015;
  37.   // The medium income
  38.   int med_income;
  39.   // The counties inside the state
  40.   struct county* counties;
  41.   // The ammount of counties inside the state
  42.   int n_counties;
  43. };
  44.  
  45. /**
  46.  * Allocate an array of a specified number of states.
  47.  */
  48. struct state *allocate_states(int);
  49.  
  50. /**
  51.  * Reads data for a specified number of states from an input file stream
  52.  * into a given array
  53.  */
  54. void read_state_data(struct state *, int, std::ifstream &);
  55.  
  56. /**
  57.  * Allocates an array of a specified number of countries.
  58.  */
  59. struct county *allocate_counties(int);
  60.  
  61. /**
  62.  * Reads data for a specified number of counties from an input file stream
  63.  * into a given array.
  64.  */
  65. void read_county_data(struct county *, int, std::ifstream &);
  66.  
  67. /**
  68.  * Releases all data allocated to given array. You must make sure to call this
  69.  * function when needed to make sure any allocated data is freed before it is
  70.  * lost or before the program exits
  71.  */
  72. void free_state_data(struct state *, int);
RAW Paste Data
Top