Hey guys,
I've been trying random ideas to parse a string of numbers into an array for a couple hours and I'm still bugging out.
This is the last thing I've tried.
Basically I want array[0]=1, array[1]=2; array[2]=3;
string array1[2];
string temp = "1 2 3";
stringstream str(temp);
int i=0;
while(str >> array[i])
{
i++;
}
//This bugs the program out
cout << array1[2];
Any ideas?
Thanks,
jktexas1
Try defining
string array1[3];
With string array1[2];
the max index you can use is 1. 2 has not been allocated.
Thank you so much that works!