so i've got this string called code, of type std::string, which has this inside it
and yes i've verified this by using cout. now im trying to read each line into a seperate element of the array statements, which is also of type std::string. when i run the below code however:
int last_flushed = 0;
std::string statements[1000];
int array_pos = 0;
for (int i = 0; i <= code.size(); i++)
{
if (code[i] == '\n')
{
statements[array_pos] = string_copy(code, last_flushed, i - last_flushed);
cout << statements[array_pos];
array_pos++;
last_flushed = i;
}
}
it just prints out this:
any idea why this is happening? ive been staring at this for a day or so, i feel really stupid right now. thanks in advance for your help.