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.