Instead of malloc, realloc, why not use std::vector and std::string? The C++ standard library shall simplify your task. Bask in it's warmth.
Code:#include <vector> #include <fstream> #include <string> /* ... */ std::vector <std::string> v; /* ... */ std::ifstream i("poem.txt"); /* ... */ // get a line from the file char buf[256]; i.getline(buf,256,'\n'); v.push_back(std::string(buf));