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
|
#include <iostream>
#include <fstream>
using namespace std;
void Data(char[], char, int);
void Over_18(char[], char, int);
void Under_18(char[], char, int);
int main()
{
char Name[100] = {}, Vote = {};
int Age = {};
Data(Name, Vote, Age);
}
void Data(char Name[], char Vote, int Age)
{
ifstream Main;
Main.open("Data.txt", ios::app);
while (!Main.eof())
{
Main >> Name;
if (Name == "0")
{
break;
}
Main >> Age;
Main >> Vote;
if (Age < 18)
{
Under_18(Name, Vote, Age);
}
else if (Age >= 18)
{
Over_18(Name, Vote, Age);
}
for (int i = 0; i < 100; i++)
{
Name[i] = -52;
}
}
}
void Under_18(char Name[], char Vote, int Age)
{
ofstream f18;
f18.open("Under 18.txt", ios::app);
f18 << "Name: " << Name << endl;
f18 << "Age: " << Age << endl << endl;
f18.close();
}
void Over_18(char Name[], char Vote, int Age)
{
ofstream f19;
f19.open("Over 18.txt", ios::app);
f19 << "Name: " << Name << endl;
f19 << "Age: " << Age << endl;
f19 << "Vote: " << Vote << endl << endl;
f19.close();
}
|