Nov 2, 2013 at 1:35pm UTC
Here is the console:
varr HelloWorld, Hello, world!;
prnt HelloWorld;
quit
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr
Aborted (core dumped)
Press ENTER to continue...
here is my main loop of code:
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
string argv = "" ;
string line = "" ;
while (line != "quit" ) {
cin >> line;
argv += line;
}
for (int i = 0; i < sizeof (argv) - 4; i++) {
if (argv.substr(i, 4) == "varr" ) {
string name = "" ;
int x = i +1;
for (x; argv.substr(x) != "," ; x++) {
name += argv.substr(x);
}
string val = "" ;
x++;
for (x; argv.substr(x) != ";" ; x++) {
val += argv.substr(x);
}
vars[name] = val;
i = x;
} else if (argv.substr(i, 4) == "prnt" ) {
string name = "" ;
int x = i +1;
for (x; argv.substr(x) != ";" ; x++) {
name += argv.substr(x);
}
cout << vars[name];
i = x;
}
}
cin.get();
cin.sync();
Okay so now I'm in debug and at that error I get:
Program Received signal SIGABRT
Stack trace is available in the 'Call Stack' tab
Last edited on Nov 2, 2013 at 2:50pm UTC
Nov 2, 2013 at 4:21pm UTC
Your loop condition on line 8 makes no sense. Presumably you meant argv.size() or argv.length() and not sizeof(argv) .