- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to concatenate multiple C++ strings on one line?
Here we will see how to concatenate multiple strings in one line in C++. There are few different methods to do that. The easiest method is by using the plus (+) operator. The strings can be concatenated using +. We can place + sign between two strings to make them concatenated.
Input: Some strings “str1”, “str2”, “str3” Output: Concatenated string “str1str2str3”
Algorithm
Step 1: Take some strings Step 2: Concatenate them by placing + sign between them Step 3: Display the string Step 4: End
Example Code
#include <iostream> using namespace std; int main() { string str1, str2, str3; str1 = "Hello"; str2 = "C++"; str3 = "World"; string res = str1 + str2 + str3; cout << res; }
Output
HelloC++World
Advertisements