Devi scrivere std::string, non string.
Amaro C++, il gusto pieno dell'undefined behavior.
Regole del Forum