// INSTALLATION: MTSU
// REMARKS: The program's goal is to pick out and print all of the valid email
// addresses in the information given and nothing else.
//
//
#include <iostream>
#include <fstream>
#include <ostream>
#include <string>
usingnamespace std;
int main()
{
string word;
int i=0;
char ch['@'];
size_t found;
ifstream fileIn;
ofstream fileOut;
fileIn.open("mail.dat");
fileOut.open("addresses.dat");
if (!fileIn)
{
cout << "Can't open the input file." << endl;
return 1;
}
while (! fileIn.eof())
{
fileIn >> word;
found=word.find_first_of(ch);
if (found!=string::npos);
{
fileOut << word;
cout << word << endl;
i++;
}
}
// close files
fileIn.close();
fileOut.close();
return 0;
}
Warnis is right, and no compiler can disallow it.
You should do something like char ch = '@';
or char ch[] = "@";
I personally do not know which one is the right one, i don't use iostream that much, eventually try them both.