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
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "slist.h"
#include "ll.C"
usingnamespace std;
void getData();
void printData();
constint 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()
{
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.