// p236.cpp - Ragged Array Example, Section 7.4.2.1. #include #include #include int main() { ifstream infile( "ragged.cpp" ); if( !infile ) return 1; const unsigned NumRows = 100; const unsigned BufSize = 1024; char * names[NumRows]; char buffer[BufSize]; unsigned j = 0; while(!infile.eof()) { infile.getline( buffer, BufSize ); names[j] = new char[ strlen(buffer)+1 ]; strcpy( names[j], buffer ); if( j++ >= NumRows ) break; } for(unsigned m = 0; m < j; m++) cout << names[m] << '\n'; return 0; }