-
using file iostream....
okay, here's my main...messy, I know, I've tried so much stuff to get it to run:
Code:
void main()
{
int i = 0;
ifstream fin("EmailTest.txt");
char s[300];
char* str = s;
MyString String(str);
while( !fin.eof )
{
fin >> str;
cout << str;
Email anEmail( str );
if( anEmail.IsValid() )
cout << 1 << endl;
else
cout << 0 << endl;
}
}
Here's what it needs to do: In your main() make a loop that would read file stream with email addresses and output file stream with 0 or 1 strings one per line.
I have tried so much stuff, and I can't get it to work. I have no idea how to do it...especially since it's a custom string class...
EDIT: I know the file output isn't there...I'm trying to get the input to work first...
-
Hello there. It makes things a little less clear when you post some code, but give no clue as to your errors and there are a lot of people on these boards that will go berserk and curse you out about it. Anyways here is a brief program that will retrieve emails from a file, which is basically the same as your code:
Code:
#include <fstream> // This is required for file streams.
#include <iostream> // This is required for input/output streams. (ie cout)
int main()
{
std::ifstream emailFile("Emails.txt"); // Open a file for inputing.
char s[300];
char* str = s; // A little redundant considering the above line is sufficient for storing input from a file, but will work nontheless.
while(!emailFile.eof()) // Notice eof is a function
{
emailFile >> str; // Read a line from the file.
std::cout << str << std::endl; // Output the line just read to the screen.
}
emailFile.close(); // All done so close the file.
return 0;
}
Hopefully the above is enough to get you on your way. Output to a file is rather similar to input, but instead of an ifstream you use ofstream.
-
Sorry about that, the problem is that it does not seem to be getting the input from the file correctly. It doesn't work with the code you posted, either.
EDIT: Oh wow, the whole problem was that it was named EmailTest.txt.txt....damn Windows for hiding extensions! haha
hours of aggrivation for THAT.
thanks.
-
Now is the time to disable extension hiding. It's one of the stupidest "features" of Windows anyway.
-
Yeah, I usually turn it off, but I just installed the windows vista beta last week, looks like I forgot :p