emalil validation

Hello all, this is my first time to the forum. Any help is appreciated. My task is to create an email validation program. My current issue is getting the isupper operation to work.

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
 #include <iostream>
#include <string>
#include <locale>
#include <cctype>

using namespace std;

int main ()
{
  
//Declare a constant variable to hold the password requirement length 
  const int MinLength = 8;
  int i = 0; 
  
//Declare a variable to hold the input data for the username 
  string username, f;
 
//Display info about password requirements 
  cout << "Time to creat a username\n";
        do{ 
  cout << "___________________________\n"  
        << "Your passsword must be:\n"   
        << "At least 8 characters long\n"
        << "It must contain the @ symbol\n"
        << "It must not contain any spaces\n"
        << "And it must contain at least 1 upper case letter\n"
        << "___________________________\n";
      
  cout << "Enter your email address as your username\n";  
  
  cin >> username; 
  
//Input validation portion:
//condition 1
  if (username.length()  >= MinLength) {
    //here is condition 2
  for (i = 0; i < username.length(); i++){
    if (isspace(username[i] >= 1)){
    //condition 3
    if ((isupper(username[1] >= 1))){
  }
    }
  }
   cout << "That's it" << endl;
  }
    else 
   {
     username = f;
     cout << "The username that you've entered is not valid\n" << endl;  
   } 
    
}while (username == f);
  return 0;

}


   
See this for how to use isupper():

http://www.cplusplus.com/reference/cctype/isupper/?kw=isupper

you set the parentheses wrong and the expression is not >= 1.
Hello mrbutta,

You might want to rethink your program. As it is you are asking the user for an e-mail address yet it looks like you are trying to validate it as a password.

Something you might find useful:

http://www.cplusplus.com/reference/string/string/find/
and
http://www.cplusplus.com/reference/string/string/substr/

The "substr" is useful to deal with the ".com" extension if you want to go that far. Otherwise you would be looking for the position and existence of the "@" and "." along with the "." position being > the position of the "@".

Hope that helps,

Andy
Handy Andy, you are the man! Thank you for your input friend! I was approaching the challenge all wrong. You were correct, I was trying to validate the email address as the password. once I perceived the code from that angle I was able to make some adjustments and now we are up and running! Many thanks friend, I will post the code shortly.
And thank you coder777, I appreciate the link that you sent as well. However, I wasn't able to utilize the char data type as they displayed in the example. I kept running into errors but the experience overall was helpful. Thanks again for your speedy reply. I will show you guys the revised version of my code in the following post.
Topic archived. No new replies allowed.