Strange error I have never seen

I'm getting the error:
" terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create
Abort (core dumped)
"
As of now I just started trying to make this program that will input user commands and am working on the "read_in" function. I was planning on testing very frequently but already I'm getting this strange error. The program compiles fine but when I run it, type in say for example "QU" and hit enter I get that error message.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;

string Read_in ();

int main ()
{
    string user_command;
    user_command = Read_in ();

}

string Read_in ()       // this is my read_in function
{
    string cmd;
    string cust_id;
    int ticket_amnt;
    string seat_loc;

    cin >> cmd;                 // the user will input in format "RQ joe 5 hi"
    if ( cmd == "RQ" )          // meaning that joe wants 5 tickets in the hi
        {                       // seating area
            cin >> cust_id;
            cin >> ticket_amnt;
            cin >> seat_loc;
        }
        else if ( cmd == "CA" )
        {
        }
        else if ( cmd == "PR" )
        {
        }
        else if ( cmd == "QU" )
        {
        }
}
terminate called after throwing an instance of 'std::length_error'
That's an exception
This caused it string Read_in ();
If you say that you are going to return something, then you ought to return something. As simple as that.

¿Do you understand why?
Realized I was testing way too soon and had not even finished the function yet. I fixed it and it's progressing well... false alarm! silly mistake on my part!
Topic archived. No new replies allowed.