Advertisement
pmcgee

Vector of vector of string

Oct 15th, 2020 (edited)
2,620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using namespace std;
  6. typedef    vector<string>  VS;
  7.  
  8. vector<VS> data1;
  9. //ofstream   file3;
  10. //ifstream   file4;
  11.  
  12. VS source {
  13.     "Plains/East/Northeast Severe Weather (June-July 2012)",
  14.             "Severe Storm",
  15.             "2012",
  16.             "3264.0",
  17.             "28",
  18.     "Hurricane Isaac (August 2012)",
  19.             "Tropical cyclone",
  20.             "2012",
  21.             "3122.8",
  22.             "9",
  23.     "Hurricane Sandy (October 2012)",
  24.             "Tropical Cyclone",
  25.             "2012",
  26.             "73494.6",
  27.             "159",
  28.     "Western Wildfires (Summer-Fall 2012)",
  29.             "Wildfire",
  30.             "2012",
  31.             "1964.6",
  32.             "8",
  33.     "U.S. Drought/Heatwave (2012)",
  34.             "Drought",
  35.             "2012",
  36.             "33903.9",
  37.             "123"
  38. };
  39.  
  40.  
  41. int main() {
  42.     data1.reserve(20);
  43.     int outer = 0,
  44.         i     = 0;
  45.  
  46.     while (i < 25) {
  47.        for (int inner = 0; inner <= 4; ++inner) {
  48.            data1[outer].push_back( source[i] );  
  49.            i++;
  50.        }
  51.        outer++;
  52.     }
  53.  
  54.    int test = 2;
  55.    for (i = 0; i <=4; ++i) {
  56.        cout << data1[test][i] << "\n";
  57.    }
  58.    cout << "\n";
  59.  
  60.    getchar();
  61. }
  62.  
  63.  
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement