HELP CREATING LINKED LIST OF VECTORS

Hi, I am trying to create a linked list of vector in my program. And, obviously, it is not working. The program is now suffering from segmentation fault. And, by the way, I know that I could write this program without using linked list; however, as a part of my assignment, I must make a use of linked list. Here is the code for the program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

//Define a class to represent each Seismic Activity measurement event...

class RedwoodBaySeismicData
{
    string LocationID; //This is the station that owns this piece of data…
    string Date; //The date that the values were collected…
    string Time; //The time of day that the values were collected…
    double SeismicSize; //Magnitude of Earthquake


  public:
    RedwoodBaySeismicData();
    RedwoodBaySeismicData(string, string, string, double);

    //The first group of member functions are used to change values...
    //Functions are defined in the form of inlines.

    void SetID(string ID)
    {
        LocationID = ID;
    }
    void SetDate(string Day)
    {
        Date = Day;
    }
    void SetTime(string Hour)
    {
        Time = Hour;
    }
    void SetSeismicSize(double Magnitude)
    {
        SeismicSize = Magnitude;
    }


    //The second group allows controlled access to individual value in the class...

    string GetID()
    {
        return LocationID;
    }
    string GetDate()
    {
        return Date;
    }
    string GetTime()
    {
        return Time;
    }
    double GetSeismicSize()
    {
        return SeismicSize;
    }



};



//The default constructor sets the private variable members to a harmless value...

RedwoodBaySeismicData::RedwoodBaySeismicData()
{
  LocationID;
  Date;
  Time;
  SeismicSize = 0.0;

}

//This initializing  constructor allows you to create a object with value already set...

RedwoodBaySeismicData::RedwoodBaySeismicData(string ID, string Day, string Hour,
  double Magnitude)
{
  LocationID = ID;
  Date = Day;
  Time = Hour;
  SeismicSize = Magnitude;

}

class RedwoodBayDataList
{
    vector < RedwoodBaySeismicData * > RedwoodBayDataSpots; 
      //Create a collection of location information...
    string FileName;
    int K;
  public:

    // void GiveRedwoodSeismicData(RedwoodBaySeismicData *X) {RedwoodBayDataSpots.push_back(X);}
    RedwoodBayDataList()
    {
        FileName = "RedwoodBaySeismicEventList.data";
        K = RedwoodBayDataSpots.size();
    }
    RedwoodBayDataList(RedwoodBaySeismicData);

    void DisplaySeismicInfo();
    void DisplayInfoForEachStation(int);
    void DisplayAlphaInfo(int)
    {

        DisplayInfoForEachStation(K);
    }
    void DisplayBetaInfo(int)
    {
        DisplayInfoForEachStation(K);
    }
    void DisplayGammaInfo(int)
    {
        DisplayInfoForEachStation(K);
    }
    void DisplayDeltaInfo(int)
    {
        DisplayInfoForEachStation(K);
    }
    void DisplayEpsilonInfo(int)
    {
        DisplayInfoForEachStation(K);
    }

};



//Allow the user to post the values for each location...

void RedwoodBayDataList::DisplaySeismicInfo()
{





  string Line, ID, Date, Hour;
  double Magnitude;

  fstream InFile("RedwoodBaySeismicEventList.data.txt", ios::in);


  string Command2;

  {
    cout << "Choices...................................................." <<
      endl;
    cout << "-----------------------------------------------------------" <<
      endl;
    cout << 
      "Enter the name of the one of the four stations below for which you would like to have the data for seismic activity" << endl;
    cout << "Alpha" << endl;
    cout << "Beta" << endl;
    cout << "Gamma" << endl;
    cout << "Delta" << endl;
    cout << "Epsilon" << endl;
    cout << "-----------------------------------------------------------" <<
      endl;
    cout << "Command: ";
    getline(cin, Command2);
  }

  RedwoodBaySeismicData *Buffer = new RedwoodBaySeismicData(ID, Date, Hour,
    Magnitude);


  cout << "\n\t============================================================="
    << endl; 
    //This section is the report...it's really all about the formatting...
  cout << "\tWeekly Report" << endl;
  cout << "\t==============================================================="
    << endl;
  cout << "\tLocation\tDate\t\tHour\tMagnitude" << endl;
  cout << "\t==============================================================="
    << endl;







  while (getline(InFile, Line))

  {

    ID = strtok((char*)Line.c_str(), ":");
    Date = strtok(0, ":");
    Hour = strtok(0, ":");

    Magnitude = atof(strtok(0, ":"));



    Buffer->SetID(ID);

    Buffer->SetDate(Date);
    Buffer->SetTime(Hour);
    Buffer->SetSeismicSize(Magnitude);
    RedwoodBayDataSpots.push_back(Buffer);





    if (RedwoodBayDataSpots.size() == 114)
      break;



  }
  InFile.close();


  if (Command2 == "Alpha")
  {
    for (K = 0; K < 23; K++)

    {
      DisplayAlphaInfo(K);
    }


  }


  else if (Command2 == "Beta")
  {
    for (K = 23; K < 47; K++)
      DisplayBetaInfo(K);
  }
  else if (Command2 == "Gamma")

  {
    for (K = 47; K < 70; K++)
      DisplayGammaInfo(K);
  }
  else if (Command2 == "Delta")

  {
    for (K = 70; K < 93; K++)
      DisplayDeltaInfo(K);
  }
  else if (Command2 == "Epsilon")

  {
    for (K = 93; K < 115; K++)
      DisplayEpsilonInfo(K);

  }







  cout << 
    "\t===============================================================\n\n" <<
    endl;
}


void RedwoodBayDataList::DisplayInfoForEachStation(int K)
{
  RedwoodBaySeismicData *Buffer;
  cout << "\t" << Buffer->GetID() << "\t\t" << Buffer->GetDate() << "\t" <<
    Buffer->GetTime() << "\t" << Buffer->GetSeismicSize() << endl;




}


//Declare the functions...

void RunIT();
void Menu();
void ChooseTheStation();


int main()
{
  RunIT();
  system("pause");
}

//This function implements a simple command processor...

void RunIT()
{
  RedwoodBayDataList RedwoodBayDataSpots;
  string Command1;
  int K;

  while (Command1 != "Quit")
  {
    Menu();
    cout << "Command: ";
    getline(cin, Command1);

    if (Command1 == "Report")
      RedwoodBayDataSpots.DisplaySeismicInfo();
  }
}

//This function tells the user what he or she can do...

void Menu()
{
  cout << "Choices...................................................." << endl;
  cout << "-----------------------------------------------------------" << endl;
  cout << "\tReport...displays the  report." << endl;
  cout << "\tQuit.....exits the program." << endl;
  cout << "-----------------------------------------------------------" << endl;
}


Any suggestions would be greatly appreciated.
Your post contains three occurrences of the word "list", and somehow none appear in the source code. So I'm confused.

1
2
3
#include <list>

std::list<std::vector<RedwoodBaySeismicData> > listOfVectors;

Topic archived. No new replies allowed.