I am trying to build a recursive funciton using static variable that would replace white space with asterik character however soemthing is amiss. I get error Runtime error time: 0 memory: 3472 signal:11
.
Code
#include <iostream>
using namespace std;
string replace(string s) {
static int n = 0;
if (n == s.length()) return s;
if (s[n] == ' ') s[n] = '*';
n++;
replace(s);
}
int main() {
string s= "ssdfa sadfs";
cout<<replace(s);
return 0;
}