Target: the valid telephone format is: 514 999-9999 (canadian national format).
We must have a regional code from a list, space and a hyphen.
Here is my code: I have an error on line dim[i]=espace;
passing const string as this argument discard qualifiers
I'm stuck, any help would be appreciated.
bool validerTelephone(const std::string& p_telephone) {
string code_reg[28]={"403","780","604","236","250","778","902","506","514","408","204","905","519","289",
"705","613","807","416","647","438","450","579","418","581","819","306","709","867"};
bool etat;
if(p_telephone.size()!=12){
etat=false;
}
else {
string mon_code_reg=p_telephone.substr (0,3);
bool pas_trouve=true;
int i=0;
while (pas_trouve){
if(mon_code_reg.compare(code_reg[i])==0)
pas_trouve=false;
char tire='-';
char espace=' ';
bool formatvalide=true;
unsigned int dim=p_telephone.size();
string telephone_valide=p_telephone;
for(int i=0;i<dim;i++){
if(i==3){
dim[i]=espace;
}
else if(i==7){
dim[i]=tire;
}
else{
cout<<"format telephone"<<p_telephone<<endl;
}
}
formatvalide=false;
}
return etat;
}
}