List is posting the right info but wrong names.

Hello I am trying to finish this program for a class moving lists to different files and such. i have gotten a majority of it done but the final part is messing me up.
My code is:

int main()
{
ifstream InputLicense;


SortedList SortedLicense;

int ReadLicense;
string ReadName;

ofstream OutputList;


InputLicense.open("licensesa.txt");

if (!InputLicense)
{
cout << "Can't open file licensesa.txt" << endl;
return 1;
}

OutputList.open("licenselist.txt");

InputLicense >> ReadLicense;

while (InputLicense && !SortedLicense.IsFull())
{
if (!SortedLicense.IsThere(ReadLicense))
{
SortedLicense.Insert(ReadLicense);

}

InputLicense >> ReadLicense;
InputLicense >> ReadName;
}

SortedLicense.Delete(200);
SortedLicense.ResetList();

while (SortedLicense.HasNext())
{
ReadLicense = SortedLicense.GetNextItem();

OutputList << ReadLicense << " " << ReadName << endl;


}


InputLicense.close();
OutputList.close();


return 0;
}

There is obviously some more info in .h files but what i keep getting is
"12091 Aikman, Thomas
18327 Aikman, Thomas
22348 Aikman, Thomas
28173 Aikman, Thomas
29106 Aikman, Thomas
30945 Aikman, Thomas
38456 Aikman, Thomas
39504 Aikman, Thomas
40593 Aikman, Thomas
48372 Aikman, Thomas
49349 Aikman, Thomas
50505 Aikman, Thomas
51093 Aikman, Thomas
60192 Aikman, Thomas
72345 Aikman, Thomas
72381 Aikman, Thomas
77463 Aikman, Thomas
82374 Aikman, Thomas
88384 Aikman, Thomas
91823 Aikman, Thomas
"
I know i kind of butchered posting this but if anyone can help or let me know a better way to post it please let me know! Thanks a lot for reading!
I have no idea what I'm doing.
Try this.
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
int main()
{
ifstream InputLicense;
SortedList SortedLicense;
int ReadLicense;
string ReadName;
ofstream OutputList;

InputLicense.open("licensesa.txt");

if (!InputLicense)
{
cout << "Can't open file licensesa.txt" << endl;
return 1;
}

else
{
OutputList.open("licenselist.txt");
InputLicense >> ReadLicense;

while (InputLicense && !SortedLicense.IsFull())
{
if (!SortedLicense.IsThere(ReadLicense))
{
SortedLicense.Insert(ReadLicense);
InputLicense >> ReadName;
}
else
{
InputLicense >> ReadName;
}
InputLicense >> ReadLicense;
}

SortedLicense.Delete(200);
SortedLicense.ResetList();

while (SortedLicense.HasNext())
{
ReadLicense = SortedLicense.GetNextItem();
OutputList << ReadLicense << " " << ReadName << endl;
}


InputLicense.close();
OutputList.close();

}

return 0;
}
Last edited on
Topic archived. No new replies allowed.