I am trying to learn c++ and this is what I have come up with. I want to apply email validation and the constraints that I want to put are -
1. first place should have alphabet only.
2. before @ there can be any alphabet, digit, _ or .
3. After @ is detected .com or .co.in should come next.
Is my approach right?
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
void getemail();
return 0;
}
void getemail()
{
string email;
int flag=0;
cout<<"enter your email id: ";
cin>>email;
for(unsigned int pos=0; pos<email.size();pos++)
{
if(isalpha(email[pos]))
{
flag=0;
}
Thanks for replying. Yes I know that my constraints will not accept many of the valid email ids but I need to start from somewhere and hence I thought of starting with this and later I can make changes(first I need to learn how to make code for validation, right?)
I am not supposed to submit this code or use it anywhere, just trying to learn. :)
Can you please help me in correcting the errors? :) I know my code is really stupid and probably of no use. :P