So, I wanted to write a function which swaps elements of strings, given their place in the string, so I wrote the following code,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void swap_element(string a, int q, string b, int w){
char o;
char p;
o = a[q];
p = b[w];
a[q]=p;
b[w]=o;
}
int main(){
string a, b;
cin >> a >> b;
swap_element(a, 0, b, 0);
cout<<a<<" "<<b;
}
Unfortunately it just outputs the original values of the strings. Suggestions?