I'm trying to to find elements into an array and look for the same elements into another array and i'm trying to assign the same ones with a 'y' for yes and 'n' for no, here is the code i did, but the code only reads it index by index, i want to mix it, could you help me please ?
for example
if i want to read the text below, my code would say 'y' for the first 4 elements into the first array then 'n'for the rest, it should read 'y' for s1
c1 c1
c2 c2
c3 c3
c4 c4
c5 s1
s1 b1
ifstream infile,missingFile;
infile.open("/Users/ea0409952/Documents/COSC1337home/abebe-lab14/deck.txt");
missingFile.open("/Users/ea0409952/Documents/COSC1337home/abebe-lab14/defective.txt");
if ( !infile || !missingFile) // in case it doesn't open
{
cout <<"Unable to open file, try again please!" << endl;
return 1;
}
/*
if (!missingFile)
{
cout << "unable to open defective file" << endl;
}
*/
string standard[52];
string sample[52] = {""};
int count = 0;
/*
while (infile >> standard[count])
{
missingFile >> sample[count];
count++;
}
*/
for (int index = 0; index < 52; index++)
{
infile >> standard[index]; //>> sample[index];
missingFile >> sample[index];
//missingFile >> defective[index];
//cout << standard[index] << " " << sample[index] << endl;
//cout << defective[index] << endl;
}
/*
while (infile >> standard[count])
{
missingFile >> sample[count];
count++;
}
*/
for (int index = 0;index < 52;index++)
{
if (sample[index] == standard[index])
{
standard[index] = 'y';
}
else
{
standard[index] = 'n';
}
cout << standard[index] << " " << sample[index] << endl;
}
//cout <<"show this: " << standard[10] << endl;
infile.close();
missingFile.close();
return 0;
}