0

i am currently working on a program that validates email addresses.

i have finished the code to open the user file and read every line in the file and processes every characater to check if there is one "@" and a "." then prints to the console.

i am now having trouble eliminating duplicate emails.

here is the code ive got so far.

string Emails;

char hasat = '@.';

int i;
while (getline(fin, Emails))
{
for (i = 0; i < Emails.length(); i++)
{
if (Emails == hasat)
{
cout << Emails << "; " << endl;
} // if
} // for
} // while

input text file:
randy@comcast.net
john@yahoo.com
apple@hotmail.com
dude@hotmail.com
BIGLETTERS@EMAIL.COM
manyahoo.com
email1@ymail.com
email2@live.com
email_3@yahoo.com
emailinvalid@yahoocom
randy@comcast.net

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Lerner
0

With STL string objects checking for duplicates is as simple as using the equals operator to compare the current string with a string stored someplace else in the program, say a container holding unique strings that have been read in so far.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.