If you're going to use C++ I/O, you might as well use the std::string class rather than a char*. And for reading in a whole line of input at a time, use getline(). For the database itself, a vector would probably be appropriate. You could do something like this (pseudo c++ code):
#include <vector>
#include <iostream>
#include <string>
int main()
{
using namespace std;
vector<string> stringDatabase;
string input;
while(true)
{
getline(cin, input, '\n'); // I forget the exact parameter order
/* find where the string goes */
/* put the string in the vector */
}
/* output the contents of the vector
}
Not sure how to handle the Ctrl-Z off-hand though...