C++
The OP asked if he could save the first and last names to some sort of a database. A text file can be considered a flat-file database so I gave him a simple example of saving to a text file.
It wouldn't be much more work to save to XML (another simple text file format). Of course he/she could establish a connection to a database management program like MySQL, PostgreSQL, MS Access, etc. and read/write to it but that's not quite as simple...