mail.dat project

hi i have this project and i need help with it, maybe someone can help me. please?
im really new and really confused.

"You're working for a company that's building an email list from files of mail messages. They would like you to write a program that reads a file called mail.dat, and that outputs every string containing the @ sign to file addresses.dat. For the purpose of this project, a string is defined as it is by the C++ stream reader-a contiguous sequence of non-whitespace characters.
Given the data:

From: [email protected]
Date: Wed, 13 Aug 2003 17:12:33 EDT
Subject: Re: hi
To: [email protected]

John,

Dave's email is [email protected]

ttyl,

sharon

Then the program would output on file addresses.dat:

[email protected]
[email protected]
[email protected].

Use meaningful variable names, proper indentation, and appropriate comments. Thoroughly test the program using your own data sets.


and this is what i have so far..and it's not working. im not really good with c++ so if someone can tell me what i am doing wrong it'll be great. thanks

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{

ifstream inFile;
ofstream outFile;
string tempString;


inFile.open("mail.dat");
outFile.open("addresses.dat");

while(inFile)
{
inFile>>tempString;
if(tempString.find('@')!=string::npos)
outFile<<tempString;

}

inFile.close();
outFile.close();
return 0;
}
you should read line by line from file , in c++ it can be done with getLine function.
Topic archived. No new replies allowed.