Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,950 questions

51,892 answers

573 users

How to declare multiline string in C++

4 Answers

0 votes
#include <iostream>

int main() {
    std::string s = "C++ is a general-purpose programming language "
                    "created by Bjarne Stroustrup as an extension "
                    "of the C programming language, or \"C with Classes\"";

    std::cout << s;
}



/*
run:

C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes"

*/

 



answered May 9, 2021 by avibootz
edited Feb 25, 2022 by avibootz
0 votes
#include <iostream>
  
int main() {
    std::string s = "C++ is a general-purpose programming language\n"
                    "created by Bjarne Stroustrup as an extension\n"
                    "of the C programming language, or \"C with Classes\"";
  
    std::cout << s;
}
  
  
  
  
/*
run:
  
C++ is a general-purpose programming language
created by Bjarne Stroustrup as an extension
of the C programming language, or "C with Classes"
  
*/

 



answered May 9, 2021 by avibootz
edited Feb 25, 2022 by avibootz
0 votes
#include <iostream>
 
int main() {
    const char* str = R"(Line1
Line2
Line3
Line4)";                    
 
    std::cout << str;
}
 
 
 
 
/*
run:
 
Line1
Line2
Line3
Line4
 
*/

 



answered Feb 25, 2022 by avibootz
edited Feb 1, 2023 by avibootz
0 votes
#include <iostream>

int main() {
    const char* str = "line1\n"
        "line2\n"
        "line3\n"
        "line4\n";

    std::cout << str;
}




/*
run:

line1
line2
line3
line4

*/

 



answered Feb 1, 2023 by avibootz

Related questions

1 answer 174 views
1 answer 120 views
120 views asked May 21, 2021 by avibootz
1 answer 150 views
150 views asked Jan 16, 2022 by avibootz
1 answer 110 views
110 views asked Apr 13, 2022 by avibootz
...