SLIDE 4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡
int main(int argc, char **argv){ char *bad; std::string input; int i = 0; Type in “step” to go into
print_message(). Once inside print_message(), type in “bt” to
print_message(); see the call stack. std::cin >> bad; input = bad; for(i = input.length(); i
Restart the program and step
>=
e; r p
i
r- in
){
message() this time
std::cout << } input[i];
by using “step” instead of “next”.
std::cout << std::endl; return 0; }
16
int main(int argc, char **argv){ char *bad; std::string input; Get to the std::cin line and type int i = 0; “step” again. print_message(); std::cin >> bad; input = bad;
At this point, the debugger is expecting you to type something in, so type in a
for(i = input.length(); i >= 0; i--){
string.
std::cout << input[i]; } std::cout << return 0;
The program
std::endl;
will crash at this point
}
17