displaying an array help

ok my getData() function reads a text file and stores it into an array called info, and everytime it reads a letter from that file it calls a member called addRear which comes from my link list class "slist". what i need help on is how could i display this information using my Printdata function and display in on the screen on a readable format like below, please any help

lets say the my text file looks something like this

A 2 B C
B 1 D
C 1 A
D 2 C A

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
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "slist.h"
#include "ll.C"
using namespace std;

void getData();
void printData();

const int SIZE = 10;

struct info
{
  char vertexName;
  int outDegree;
  slist adjacentOnes; // this comes from slist.h which is a link list class                                                   
};


int main()
{



}

//PURPOSE: GETS DATA FROM THE FILE                                                                                            
void getData()
{
 ifstream fin("table.txt"); // opens the file
  string line; // declares line as a string

  // goes on a for loop and reads every variable, if variable is
  // a letter it calls addRear and appends it to the back of a list
  for(int i = 0; i<SIZE && getline(fin, line); i++)
    {
      istringstream S(line);
      S >> table[i].vertexName >> table[i].outDegree;
      char x;
      while(S >> x)
        table[i].adjacentOnes.addRear(x);
    }
  }


 }

void printData()
{
You clearly know how to loop through data, so why not just loop through your data and print it out as you go through it?
i got help from someone on how to loop through the data, but im suppose to use another function to display the data. On my link list class "slist" there is also a member called displayAll which displays all the elements on the link list. So im suppose to use that on my printData function somehow
If you are using that for loop, then it would be a relatively easy task as you have control over the increment statement. What you do is understand how the loop works so you can use that as reference to your future projects. You can have a loop with in a loop or some if statement to get you your desired output.
Topic archived. No new replies allowed.