How to converted string with space in double quoted string. For Example: I get string
c:\program files\abc.bat
I want to convert this string to "c:\program files\abc.bat" but only if there is space in the string.
How to converted string with space in double quoted string. For Example: I get string
c:\program files\abc.bat
I want to convert this string to "c:\program files\abc.bat" but only if there is space in the string.
Search for white spaces. If found add \" to the front and the end of the string. That would be an escaped quotation mark.
std::string str = get_your_input_somehow();
if (str.find(" ") != std::string::npos) {
str = "\"" + str + "\"";
}
Assuming the STL string s contains the string you want to check for a space:
if (s.find(' ') != std::string::npos)
{
s = '"' + s + '"';
}