Issue with linked list and file IO

Hi, I'm having a lot of trouble understanding the very basics of a linked list in c++. Can't find a lot of examples about saving file parameters in a linked list. After hours of tries and errors, I finally decided to submit a topic about my problem.

I'm trying to read a .don file who looks like this

1
2
3
4
5
1770 0.12
2772 0.41
2884 0.04
7897 0.02
5661 0.01


And there is the code
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
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <sstream>
#include <set>
#include <locale>


using namespace std;



typedef struct clients* PtrClients;
typedef struct clients
{
        int       clientId;
        float     rebate;
        PtrClients next;
        PtrClients prec;        
} clients;



//Find function

PtrClients findRebate(PtrClients list, int val, int nb)
{
       
       list = NULL;
       for (int i=1; i <= nb; i++)
        {
        cout <<"id="<< i << endl;  
    
system("pause");
                
              if (list->clientId == val) return list;
              else
              {
                 list = list->next;
              }
         }     
         return NULL;
}                                

int readCli(clients c[]){
     
     int client;
     float rebate;
     int i =0;
    // File
    ifstream fileIn("clients.don", ios::in);

    // Test 
    if (!fileIn) {
       cerr << "Error opening the file" << endl;
       system("pause");
       exit(1);
    }
    
    while (fileIn>>c[i].clientId>>c[i].rebate){
             i++;
    }
    fileIn.close();
    return i;
}

int main()
{
    clients  cli[5];
    int nbCli = readCli(cli); 
    PtrClients list = cli;
    list=findRebate(list,2884,nbCli);
    if (list == NULL)
        cout << "Not found" << endl;
    else    
        cout <<list<< endl;  
    
system("pause");
}


Unfortunately my code doesn't work. What I need is to reach the rebate parameter (the float in the second column) by inserting the client parameter (first int) . I need to do that to node this file with another file (so , creating a double linked list) who is going to give me more information about every specific client. But, because I can't even catch a parameter, I'm pretty lost.

I hope to find a solution. Or at least a link when I can find everything needed.Thanks!

* by the way, it has to be a linked list.
Hi, I'm having a lot of trouble understanding the very basics of a linked list in c++.

not shore if there is any reference to learn linked list but you may find it useful to have a look on my example of creating a linked list in this post (3.th reply)
http://www.cplusplus.com/forum/beginner/55351/
Topic archived. No new replies allowed.