Firstly, I think you mean std::string .
Secondly, your line is empty.
Third, if you can use the [] operator to modify an element in a string, you cannot use it to insert an element where it does not exist:
std::string a = "12"; a[0] = '3';
To do this, you must ensure that your line has allocated enough memory. Therfore
std::string a = "12"; a[0] = '3';
Fourth, you might want to:
#include <string> #include <iostream> int main() { std::string a = "12"; std::cout << a; }
Carl
source share