in the following code, I use a pointer to a C ++ string in the change () function.
In any case, should you use string class operators when working with a pointer to a string? For example, at () works for the [] operator, but is there a way to use the [] operator?
#include <string>
#include <iostream>
using namespace std;
void change(string * s){
s->at(0) = 't';
s->at(1) = 'w';
}
int main(int argc,char ** argv){
string s1 = "one";
change(&s1);
cout << s1 << endl;
return 0;
}
source
share