What i have to do is read a string into a vector, then cop that vector into an array of character pointers, then for each element in the vector i have to allocate a new character array andcopy the data from the vector element into that character array. Then finally insert a pointer to the character array into the array of character pointers...
This is what i have, with my error messages pointed out in my code... i think i did what i need to do, just with a few new to c++ errors.
also if anyone has advice on how to make this program easier please post it. I feel like im making this way too hard
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector <string> hold;
string stemp;
int size = 10;
char *carr[size];
while( getline( cin, stemp) )
hold.push_back( stemp );
for ( int i = 0; i < hold.size(); i++ ){
char *pca = new char[ 100 ];
if( i >= size ){
size += 10;
char *ctemp = new char[ size ];
for( int j = 0; j < i; j++ )
ctemp[j] = carr[j]; <<error: invalid conversion from `char*' to `char'
delete [] carr;
carr = ctemp; <<error: incompatible types in assignment of `char*' to `char*[((unsigned int)((int)size))]'
}
carr[i] = pca;
cout << carr[i] << endl;
}
return 0;
}