C++ Program to initiate through command line

The following program is what I have so far. it reads from a pat.txt (patient list) and don. txt (doner list).
pat.txt
Patients 5
Androf O heart 24 2012
Blaren B kidney 35 2010
Cosmer AB heart 35 2007
Eralod O heart 53 2009
Forend B kidney 31 2003
don.txt
Donor 5
Zerk AB heart 20 2009
Rampe A kidney 31 2005
Darech B kidney 34 2008
Seo A kidney 26 2010
Yuio B kidney 26 2013

The code is as follows:
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "organANDbloodCOMPARE.h"
#include "RecentdonANDlongestpat.h"
#include "pat.h"
using namespace std;

struct Person{
	string surname;
	string BType;
	string organ;
	int age;
	int year, ID, IDp;
} Patient[50], Donor[50];

int i;
int i1;

void compare(){

	for (i = 0; i < 5; i ++){
			for (i1 = 0; i1 < 5; i1++){
					if (Patient[i].BType == Donor[i1].BType){
						if (Patient[i].organ == Donor[i1].organ){
							cout << "Compatible Match: " << Patient[i].surname << "  "<< Donor[i1].surname << "  " << Patient[i].BType << " and " << Donor[i1].BType << "  Organ: " << Patient[i].organ << " " << Donor[i1].organ<< "\n";
					}
				}
				//else
					//cout << "\nNo match was found\n";
			}
		}
}

void certainblood(){

	string letter;
	cout << "Please choose a letter for bloodtype list: ";
	cin >> letter;

	if (letter == "A" | letter == "a"){
			for (i = 0; i < 5; i++){
				if (Patient[i].BType == "A")
					cout << Patient[i].surname << "\n";
			}
			for (i1 = 0; i1 < 5; i1++){
				if (Donor[i1].BType == "A")
					cout << Donor[i1].surname << "\n";
				}
	}

	if (letter == "B" | letter == "b"){
			for (i = 0; i < 5; i++){
				if (Patient[i].BType == "B")
					cout << Patient[i].surname << "\n";
			}
			for (i1 = 0; i1 < 5; i1++){
				if (Donor[i1].BType == "B")
					cout << Donor[i1].surname << "\n";
				}
	}

	if (letter == "AB" | letter == "ab" | letter == "Ab" | letter == "aB"){
			for (i = 0; i < 5; i++){
				if (Patient[i].BType == "AB")
					cout << Patient[i].surname << "\n";
			}
			for (i1 = 0; i1 < 5; i1++){
				if (Donor[i1].BType == "AB")
					cout << Donor[i1].surname << "\n";
				}
	}

	if (letter == "O" | letter == "o"){
			for (i = 0; i < 5; i++){
				if (Patient[i].BType == "O")
					cout << Patient[i].surname << "\n";
			}
			for (i1 = 0; i1 < 5; i1++){
				if (Donor[i1].BType == "O")
					cout << Donor[i1].surname << "\n";
				}
	}

}

void longestpatient(){

	int a;
	int smallest = Patient[0].year;
	for (i = 1; i < 5; i++){
		if (Patient[i].year < smallest){
			smallest = Patient[i].year;
			a = i;
		}

	}

	cout << smallest << "  " << " Name of the patient: " << Patient[a].surname;

}


void longestpatrecentdon(){
	//if ((Patient[i].BType == Donor[i1].BType) && (Patient[i].organ == Donor[i1].organ)){

		int a, b;
		int smallest = Patient[0].year;
		for (i = 1; i < 5; i++){
			if (Patient[i].year < smallest){
				smallest = Patient[i].year;
				a = i;
			}

		}

		cout << smallest << Patient[a].surname;

		int small = 3000;
			for (i1 = 1; i1 < 5; i1++){
				if (Donor[i1].year < small){
					small = Donor[i1].year;
					b = i1;
				}
			}

			cout << "  " << small << Donor[b].surname << "\n";



	}

int main (int argc, char * argv[]){

	ifstream myfile("pat.txt");
	if (myfile.is_open()){
	string numpat;
	int num;

	myfile >> numpat;
	myfile >> num;

		for (i = 0; num > i ; i++){

			myfile >> Patient[i].surname;
			myfile >> Patient[i].BType;
			myfile >> Patient[i].organ;
			myfile >> Patient[i].age;
			myfile >> Patient[i].year;
			Patient[i].ID = 472-i;

		}
		myfile.close();

	}


ifstream myfile1("don.txt");
		if(myfile1.is_open()){
		string numpat1;
		int num1;

		myfile1 >> numpat1;
		myfile1 >> num1;

			for (i1 = 0; num1 > i1 ; i1++){

				myfile1 >> Donor[i1].surname;
				myfile1 >> Donor[i1].BType;
				myfile1 >> Donor[i1].organ;
				myfile1 >> Donor[i1].age;
				myfile1 >> Donor[i1].year;
				Donor[i1].ID = 297-i1;

			}
		myfile1.close();
		}

/*if (argc >= 2){
if (atoi(argv[1]) == 1){
	compare();

	}

}*/


}


There are two problems with the code. The main problem is trying to figure out why compare is not outputing with the file ins. When i run it through eclipse, it runs fine, however when implementing the argc,argv for command line, it sees the compare function and goes to it, however data read from the files for some reason does not seem to want to be implemented within that function. Is there anyone here that could possibly see why thats the case? The second is that the longestpatrecentdon is outputing the opposite, that is, its outputting the most recent patient and longest donner. By recent and longest i mean years. Any suggestions would really help as I have spent countless hours trying to figure any possibilities as to why it dosen't work. The command line is of primary concern though.
Topic archived. No new replies allowed.