Code:
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
int blanks=0;
string post, name, line;
ofstream outf("post.html");
if(!outf)
{
cerr << "couldn't open file" << endl;
exit(1);
}
//get name
cout << "Enter your name: ";
getline(cin, name);
outf << "<HR>" << name << "<HR>" << endl;
cout << "Enter your post (add 2 blank lines to finish) " << endl;
//get post (reads till empty line)
while(1)
{
getline(cin, line);
if(line == "")
{
blanks++;
if(blanks==2)
break;
}
else
{
blanks=0;
outf << line << endl;
}
outf << "<BR />" << endl;
}
outf.close();
return 0;
}