Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double Quoted Strings in C++

Tags:

c++

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.

like image 883
Avinash Avatar asked Dec 11 '25 06:12

Avinash


1 Answers

Assuming the STL string s contains the string you want to check for a space:

if (s.find(' ') != std::string::npos)
{
  s = '"' + s + '"';
}
like image 125
Ton van den Heuvel Avatar answered Dec 12 '25 19:12

Ton van den Heuvel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!