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.
#include <iostream>
usingnamespace 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;
}
elseif ( cmd == "CA" )
{
}
elseif ( cmd == "PR" )
{
}
elseif ( 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.
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!