cpp-cheatsheet icon indicating copy to clipboard operation
cpp-cheatsheet copied to clipboard

Operator missing?

Open justf0rfun opened this issue 6 years ago • 2 comments

I am just refreshing my c++ syntax knowledge has been unused for years. Isn't there an operator like '+' missing in the literals section at line

"hello" "world" // Concatenated strings

Shouldn't it be?

"hello" + "world" // Concatenated strings

justf0rfun avatar Sep 18 '19 09:09 justf0rfun

Try this anywhere e.g. in a cout statement: cout<< "abcd" "efgh"<<endl;

Output: abcdefgh

smnasirhussain avatar Sep 18 '19 17:09 smnasirhussain

@justf0rfun @smnasirhussain Using Sting header file you can Concatenate the two string variables. as shown below (mentioned at section string-Variable sized character array in the cheat sheet).

#include // Include string (std namespace) string a="Hello"; string b=" World"; cout << a+b;

Output: Hello World

@mortennobel Please close this issue.

Neeraj2K18 avatar Jan 07 '21 23:01 Neeraj2K18