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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.