cin from a file with use of pointers, struct

It seems like its always something new that I'm having trouble with. If anyone can help me that would be great. I enjoy this stuff, but its so hard to wrap my head around sometimes.

Anyways, the problem this time is i have to cin a series of values and information from an outside file.
The struct has to be defined as this:
1
2
3
4
5
6
7
 struct Node {
string parts;
int date;
int score;
float price;
Node* next;
};


With my very limited knowledge of how pointers work (or structs), I really have no idea where to start or how to do it.

I just need a place to start. External links, suggestions, etc. anything would be great.

aside from this, the information looks like:

KENMORE PUR ULTIMATE II WATER FILTER
20070623
730
49.12

KENMORE WATER FILTER
19990529
615
24.95

etc.


It seems that just teaching with a powerpoint, and giving no examples, isnt doing justice for me as a student.

using this information also i need to construct several functions dealing with max and min and averages of prices.

If anyone could even give examples, or help in my understanding of this, that would be great.

Thank you.
google/search this site for "linked list"

With my very limited knowledge of how pointers work (or structs)

...and read the tutorial on these too
Thank you,
This is what I have so far..

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
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

struct Node 
{
string parts;
int date;
int score;
float price;
Node* next;
};

void Read(ifstream& inFile, Node& information);
void Print(Node& information);

int main ()
{
Node  information;
Node* head;
Node* current;

    ifstream inFile;
    inFile.open("a7.txt");
	
	if (!inFile)
		{
			cout << "Cannot open file." << endl; 
			return 0;
		}
 

information.next = NULL;
head = &information;
current = &information;

void Read(ifstream inFile);
void Print(Node information);
  system("Pause");
}

    
    
    

       void Read(ifstream& inFile, Node& information) 
{
    int count = 0;
   Node* head;
Node* current;
	while (inFile)
	{
          inFile >> information.parts
                 >> information.date
                 >> information.score
                 >> information.price;
                 count++    ;
                 information.next = NULL;
head = &information;
current = &information;;             }
  
     
     
        
}
      
        void Print(Node& information)
{
     for (int count = 0; count < 50 - 1; count++)
     {
         cout << information.parts
                 << information.date
                 << information.score
                 << information.price;
              }
              }
i know i am not reading these things in right. I'll update after I read some more.
changed my functions to this.
seems better,
still no output though.
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
       void Read(ifstream& inFile, Node& information) 
{
    int count = 0;
   Node* head;
Node* current;

                 information.next = NULL;
head = &information;
current = &information;
for (int count = 1; count <= 3; count++)
{
    head = new Node;
    inFile >> head->parts
                 >> head->date
                 >> head->score
                 >> head->price;
    current->next = head;
    current = head;
}
  
     
     
        
}
      
        void Print(Node& information)
{       Node* current;
     for (int count = 0; count < 50 - 1; count++)
     {
      cout << current->parts
                 << current->date
               << current->score
               << current->price;
               current = current->next;
        
              }
              }


Topic archived. No new replies allowed.