NUL char in strings in C++ -
in below code trying replace first character '\0'
.
i expected print empty string, in output omits , displays rest of characters.
int main() { string str; cin >> str; str[0] = '\0'; cout << str << "\n"; return 0; }
output :
testing esting
how terminate string in c++?
ps: trying approach of terminating string in different question in need terminate in between.
std::string
not null terminated string. if want empty use clear()
method. if want remove element of string use erase()
method.
Comments
Post a Comment