I am trying to create an array out of a string input.
string input;
getline(cin,input);
string inputarray1[100];
istringstream pp(input);
int* inputPosition=0;
while (!pp.eof())
{
getline( pp, inputarray1[*inputPosition], ' ' );
inputPosition++;
}
int* a = inputPosition;
string halp[a];
I am using getline to parse my input (along with an istringstream) and placing that into an array, but how can I create an array that has no extra empty locations?
Use a vector, from the header
<vector>The number of strings can be obtained with
inputArray.size(), and you can access individual elements just like with an array,inputArray[index].Note that
operator>>is delimited on whitespace, so you can probably also do this(unless you for some reason want to treat tabs differently)