ged.suse@ntlworld.com wrote:
How do I insert a textfile of stings, separated by carrige returns into an string array, or an array of pointers.
I would suggest you use the STL container vector<string> to hold the strings. This allows you to manipulate the object as if it were an array without having to worry about pointers, memory allocation and buffer overruns as you would if you were programming in C. You'll need to use #include<vector> to get this. Here's my version. You'll probably need to tweak this a bit to make sure it works. #include<iostream> #include<fstream> #include<vector> int main(){ std::vector<std::string> names; std::ifstream fpi("names.dat"); while( fpi.good() ){ std::string name; std::getline( fpi, name ); names.push_back( name ); } exit(0); } Now you can refer to a string as names[i] where i is an int in [0, names.size()). You can even use tricks like std::copy( names.begin(), names.end(), std::ostream_iterator<std::string>( std::cout, "\n" ) ); to print off the whole list of strings to standard output. The C-style version of this also works: for( int i = 0; i < names.size(); ++i ) std::cout << names[i] << std::endl; Vectors and strings are a little less efficient than arrays of char*, but IMHO, for most IO it's better to have simple robust code than efficient code that's difficult to check for runtime bugs. -- JDL Non enim propter gloriam, diuicias aut honores pugnamus set propter libertatem solummodo quam Nemo bonus nisi simul cum vita amittit.