So here is my mistake:
terminate called after throwing an instance of 'std::length_error' what(): basic_string::_S_create Aborted (core dumped)
and here is my code:
//Code removed string generateSong(string list[], int num) { //Code removed //Code removed for (i = 0; i < num; i++) { output += list[i]; output += bone1; output += list[i + 1]; output += bone2; } return output; } int main() { string list[9] = { //Code removed }; //Code removed return 0; }
I just wanted to know what this error means, so I know how to fix it. I have seen many posts with similar errors, but nothing exactly the same. I'm literally just starting out in C ++, and none of these answers make sense with what I have learned so far. As you can see, this is a simple song output program. It helped me train the strings for the class that I take, but for me it makes absolutely no sense, and the book doesnβt help much either. Can anyone explain this to me?
PS In case it is useful, it will be compiled using g ++, but when it starts, it will give this error (so basically this is not a compilation error, this is a startup error).
c ++ string runtime-error
scbeacham
source share