#include<iostream>
#include<string>
using namespace std;
void reverse(string s){
if(s.length()==0){ //base case
return;
}
string ros=s.substr(1);
reverse(ros);
cout<<s[0];
}
int main(){
reverse("binod");
}
debugger_img_1
debugger_img_2
PFA, The debugger is supposed to step into the reverse() function. But it is opening these external codes.
The debugger is stepping into the std::string(const char*) constructor. Your code calls this implicitly before calling reverse because you pass "binod" (which effectively has type const char*) to a function expecting a std::string.
There's nothing wrong here, it's not the wrong function, just a function you didn't realise was being called. Just step out and then step in again.
Side note: Visual Studio's debugger has the 'Just My Code!' feature which, when enabled, means the debugger only steps into code you wrote. Can be a useful time saver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With