I want to design a parser that will parse news articles that come to my news inbox, so I'm learning as I go, for now, all I want is a basic program that will output mail back to the inbox, and write it to file, this is just to get started so I know what works, what does not, etc.
Here's my code so far:
Code:
int main()
{
char a;
fstream fout("/data/samba/shared/ryan/applications/news_parser/procmailtest.log",ios::out);
for(int i=1000;i>0;i--)
{
a = getchar();
cout<<a;
fout.put(a);
}
fout.close();
return 0;
}
I can't figure out how to programaticly know when to stop, (I think it has to do with the content-lenght header, but I'm not there yet) so that's why I just read 1000 chars.
My problem is that the email is NOT being outputted to the procmailtest.log file, the file does not even get created. But the email does successfully make it to the inbox. (a little corrupted though, because it ads/removes chars depending on the size of the email but that I know why).
So how do I get it to write the email to file? If I run this program directly and type stuff, it will write the file properly.
I'm also sending emails bigger then 1000 chars to ensure the program does end so the fout.close does get called. I even tried opening and closing a file right at the start and it does not even work either, so really not sure what's going on.