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
|
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main () {
string line;
string consonantBank [351][2];
string vowelBank [141][2];
const char baseVowels [] = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
int y=0, q=0;
ifstream myfile ("upsidtestcomma3.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
if (line.find_first_of(baseVowels) != line.npos)
{
vowelBank [q][0] = line;
line.clear();
getline (myfile,line);
vowelBank [q][1] = line;
line.clear();
++q;
}
else {
consonantBank [y][0] = line;
line.clear();
getline (myfile,line);
consonantBank [y][1] = line;
line.clear();
++y;
}
}
myfile.close();
}
else cout << "Unable to open file.";
for(int i=0; i<351; i++)
{
cout << consonantBank[i][0] << "," << consonantBank[i][1] << "\n";
}
cin.get();
for(int i=0; i<141; i++)
{
cout << vowelBank[i][0] << "," << vowelBank[i][1] << "\n";
}
cin.get();
cout << vowelBank[20][0] << "," << vowelBank[80][0] << "," << vowelBank[110][0] << "\n";
cout << consonantBank[20][0] << "," << consonantBank[150][0] << "," << consonantBank[300][0] << "\n";
cin.get();
return 0;
}
|