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