i have function test input mail, but when i have run it, error happen thats Assertion, can you help me, fix it, i dont know fix where.thanks
Code:
//CheckerMail.h"
#include"string"
using namespace std;
class CIMail{
public :
static bool checkpart1(char &chr);
static bool checkpart2(string &str);
static bool checkpart3(string &str);
//static bool checkpart4(string &str);
static int checkchar(string &str);
};
//CheckerMail.cpp"
#include "string"
#include <iostream>
#include "CheckerMail.h"
using namespace std;
bool CheckerMail::checpart1(string &par1){
if(par1.length()==0)return false;
int k=indexdot(par1);
for(int i=k+1;i<sizeof(par1);i++)
if(check(par1[i])){
return true;
}
return false;
}
bool CheckerMail::checper2(string &par2){
if(par2.length()==0)return false;
int h=indexa(par2);
int j=indexdot(par2);
for(int i=h+1;i<j;i++)
if(check(par2[i])||(par2[i]=='.')||(par2[i]=='_')){
return true;
}
return false;
//return true;
}
//
bool CheckerMail::checper3(string &par3){
if(par3.length()==0)return false;
int index=indexa(par3);
for(int i=0;i<index;i++)
if(check(par3[i])||(par3[i]=='%')||(par3[i]=='+')||(par3[i]=='-')||(par3[i]=='.')||(par3[i]=='_')){
return true;
}
return false;
}
//
int CheckerMail::indexa(std::string &str){
for(int i=0;i<sizeof(str);i++){
if(str[i]=='@')return i;
}
return 0;
}
int CheckerMail::indexdot(std::string &str){
int k=0;
for(int i=0;i<sizeof(str);i++){
if(str[i]=='.')
return i;
}
//return k;
return 0;
}
//@
bool CheckerMail::check(char &par){
if((par>='a')&&(par<='z')||((par>='A')&&(par<='Z')))
return true;
return false;
}
//
bool CheckerMail::checmain(std::string &par){
if(!checper2(par)||!checper3(par)||!checpart1(par))return false;
return true;
//return false;
}
///main
#include "string"
#include <iostream>
#include "CheckerMail.h"
using namespace std;
void main(){
string str;
cin>>str;
cout<<CheckerMail::checmain(str);
}