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
|
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
//#include <bits/stdc++.h> ???
#include <fstream>
using namespace std;
void enterEmail(string& email, int& e);
void checkEmail ( string& email,int& e, char emaila[], bool checkamp, int percheck, bool checkper);
void enterPassword(string password, int& p);
void checkPassword(int& p, string password,char pasworda[],bool checklow,bool checkup,bool checksymbol);
void upload(string email, string password);
int main()
{ string email,
password;
int e{0},
p{0},
percheck{0};
char emaila[e+1],
passworda[p+1];
bool checkamp=false,
checkper=true,
checksize=false,
checklow=false,
checkup=false,
checksymbol=false;
for(int i=0;i<3;i++)
{
enterEmail(email, e);
checkEmail (email, e,emaila,checkamp,percheck, checkper);
enterPassword(password, p);
checkPassword( p, password, passworda, checklow, checkup, checksymbol);
upload(email, password);
}
}
void enterEmail( string& email, int& e)
{ cout<<"email: ";
cin>>email;
e = email.length();
}
void checkEmail( string& email,int& e, char emaila[], bool checkamp, int percheck, bool checkper)
{
strcpy(emaila, email.c_str());
for(int i=0;i<e+1;i++)
{
emaila[i];
if(emaila[i]='@')
{
checkamp= true;
i=percheck;
}
}
if (emaila[percheck + 1] == ('.')||emaila[percheck + 2] ==('.'))
{
checkper = true;
}
else if(checkamp==false)
{
cout<<"Sorry you neeed a @\n";
enterEmail(email,e);;
}
if(checkper==false)
{
cout<<"Sorry you neeed a .\n";
enterEmail(email,e);
}
}
void enterPassword(string password, int& p)
{
cout<<"\nPassword";
cin>>password;
p = password.length();
}
void checkPassword(int& p, string password,char passworda[],bool checklow,bool checkup,bool checksymbol)
{
if(p<9)
{
cout<<"Sorry your password must be at least 9 characters";
enterPassword(password, p);
}
strcpy( passworda, password.c_str());
for(int i=0;i<p+1;i++)
{ passworda[i];
if(islower(passworda[i]))
{
checklow=true;
}
else if(isupper(passworda[i]))
{
checkup=true;
}
else if (ispunct(passworda[i]))
{
checksymbol=true;
}
}
if(checkup==false)
{
cout<<"Sorry your password seems to be missing a uppercase letter/n";
enterPassword(password, p);
}
if(checksymbol==false)
{
cout<<"sorry your password needs a symbol/n";
enterPassword(password,p);
}
if(checklow==false)
{
cout<<"sorry your password needs a undercase letter /n";
enterPassword(password,p);
}
}
void upload( string email, string password)
{
ofstream fout;
fout.open("email.txt",ofstream::app);
fout<< email<<"\n";
fout<< password<<"\n";
}
|