Text File

I have two questions about writing to a text file. I've made and revised a program (thanks too some people on an earlier post), but I was wondering how a code to check to see if somethign were to exist would look like(and read what it has if it's true then compare it to something else).

Also, I'm making a program for our church. The user types in their information, then it saves it to a text file. The next upgrade from that is to email it, (if you know how please post a code). I've tried using streamwriter and
1
2
3
myfile.open("textfile.txt", ios::app);
myfile << whatever;
myfile.close();


However, neither of them work. Can you please help me out. Here's a link to download the program for the church.

https://rapidshare.com/files/459825879/GraceAG.exe
you would to check if a file exists? this is what i would do
1
2
3
4
5
6
7
8
9
ifstreamObject.open("someFile.txt");
if(ifstreamObject.fail())
{
   //code corresponding to the nonexistence of the file
}
else
{
   //code corresponding to the existence of the file
}

Thanks. How would I read the file (only the first line would have any words) then compare it to something?
how to read from a file? use getline() or the stream extraction operator. if that's not specific enough, you should read this:

http://www.cplusplus.com/doc/tutorial/files/
Thanks, I got it working. But I still need the API version.
Topic archived. No new replies allowed.