Email Address Validation

hi guys, i am wondering how to tackle this problem, please help.

***the most important thing is
no string, array or break is allowed for this programmme.

for the entry i may first input in a format like:
name <email>
e.g. june <june@xxx.com>

Rules are :
1. contain only one @
2. no consective dots


The output should be look like
name <email>
1 ok
2 ok
3 ok
4 ok
5 ok

or

name <email> (failed case)
1 ok
3 ok

can someone give me some clues?Thanks!!
Last edited on
If you cant use an array or string, then you need to calculate for each character:

This will print whatever you type in:
1
2
3
4
5
cout << "Please enter some things and then hit enter\n: ";

int ch;
while ((ch = cin.get()) != '\n')
  cout << ch;


So number 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cout << "Please enter some things and then hit enter\n: ";

int ch;
int atCount = 0; 
while ((ch = cin.get()) != '\n')
{
  switch(ch)
  {
  case '@':  ++atCount;  break;
  
  // Add the other important character events here
  }
}

if (atCount == 1) cout << "1 ok\n";

[/code]
Last edited on
He had better make use of an if...statement since the use of break is disallowed
yes the three important things are no array no string and no break...
can anyone help me?
I think they just did, if that is not clear, ask a question. Post your code so we can give comments
Last edited on
It says nothing about the use of continue;.

Use a for-loop, one iteration. When a 'rule' is broken continue; to restart the loop.
Topic archived. No new replies allowed.