there is a string, I want to make a pointer to it and directly change the first element through the pointer:
#include <iostream> #include <string> using namespace std; int main() { string a = "abcdefg"; string* b = &a; cout << a << endl; b[0] = "b"; cout << a << endl; return 0; } but when compiling I get the answer
abcdefg b if i try b[1] = "c"; then the answer will be:
abcdefg abcdefg
b[0] = "b". Well, directly through the pointer you can write what you wanted and, for example, like this:b->operator[](0) = 'b';:) - Harry