M
Mike Copeland
Is there any std::string function that will either force the value of
a variable to be no more than a maximum number of characters or fill it
if it's less? For example:
std::string someStr1 = "The Phantom Spitter was here.";
where I want 20, but _no more_ than 20, characters to be displayed. But
with:
std::string someStr2 = "Kilroy here.";
I want the output display to be 20 characters.
In other words, I want a substr of a string value if it's >20
characters, but I want to have the value "padded" when it's less than 20
characters. I know that setw() will pad/fill the data, but is there
something that will either fill or truncate a string to a specified
length, depending on its length? TIA
a variable to be no more than a maximum number of characters or fill it
if it's less? For example:
std::string someStr1 = "The Phantom Spitter was here.";
where I want 20, but _no more_ than 20, characters to be displayed. But
with:
std::string someStr2 = "Kilroy here.";
I want the output display to be 20 characters.
In other words, I want a substr of a string value if it's >20
characters, but I want to have the value "padded" when it's less than 20
characters. I know that setw() will pad/fill the data, but is there
something that will either fill or truncate a string to a specified
length, depending on its length? TIA