why segmentation fault is arising , because of these three lines?


The code is giving segmentation fault. But it is working fine, :

  1. if i remove the first weird line “q++;”. Or
  2. if i call solve(s,1) in main function instead of solve(s,0) at third weird line.
  3. the code is working fine if i use “solve(s,q)” at second weird line.
 ''' #include using namespace std;  >bool solve(string s,int q) {     q++; //first weird line     if(q==10)         return true;     solve(s,q+1);//second weird line     return false; }  int main() {     string s;     cin>>s;     solve(s,0);//third weird line      return 0; }'''