how to clear a string variable in cpp code example Example: how to clear a string in c++ str.clear();