Recommended Answers
Jump to PostIt's a character string? Just set the first character to be a terminator and it'll be treated as "".
name[0] = '\0';
If it's a C++ string you can call the clear method and that truncates the string to be "".
name.clear();
Jump to PostAre you talking about C++ strings or C-style char arrays? (I assume you're talking about char arrays, based on your post)
What do you mean by "completely empty"?
You can make a C++ string blank by doing this
std::string name = "hello"; std::cout << name; …
Jump to PostHow do you clear a string in a single statement ?
for egs. i want to clear name[20] of all its contents and leave it completely emptychar name[20]; memset(name, 0, sizeof name);
Although typically clearing all elements of a string is unnecessary.
Jump to PostThe problem is unlikely to be with their code but rather ... you're using the outdated version of turbo c, which is probably very likely :)
So you claim that the outdated versions of C/C++, like Turbo, never handled strings correctly? :icon_rolleyes: Or is it that after new versions came …
All 16 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.