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
|
#include <iostream>
#include <fstream>
using namespace std;
void Displayer(int, int, char[], char[]);
void IdDisplay(int);
void NameDisplay(char[]);
void NumberDisplay(int);
void EmailDisplay(char[]);
int main()
{
int Id{0}, Number{0};
char Name[20], Email[30];
Displayer(Id, Number, Name, Email);
return 0;
}
void Displayer(int I, int N, char A[], char E[])
{
ifstream Main;
Main.open("Users.txt");
if(!Main.is_open())
{
cout << "No such file\n";
exit(1);
}
char Word1[20], Word2[20];
while (Main >> Word1 >> Word2)
{
cout << "Word1 = " << Word1 << " Word2 = " << Word2 << '\n';
if (Word1[0] == 'I')
{
IdDisplay(stoi(Word2));
}
else if (Word1[1] == 'a')
{
NameDisplay(Word2);
}
else if (Word1[1] == 'u')
{
NumberDisplay(stoi(Word2));
}
else if (Word1[1] == 'm')
{
EmailDisplay(Word2);
}
else
{
cout << "Word1 has no use\n";
}
}
}
void IdDisplay(int I)
{
std::ofstream outfile;
ofstream f1;
f1.open("Ids.txt", std::ios_base::app );
f1 << I << endl;
}
void NameDisplay(char A[])
{
ofstream f2;
f2.open("Names.txt", std::ios_base::app );
f2 << A << endl;
}
void NumberDisplay(int N)
{
ofstream f3;
f3.open("Numbers.txt", std::ios_base::app );
f3 << N << endl;
}
void EmailDisplay(char E[])
{
ofstream f4;
f4.open("Emails.txt", std::ios_base::app );
f4 << E << endl;
}
|