473,225 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Are there any long C string across multiple lines

Hi,

In python, triple quote (""") can be used to quote a paragraph
(multiple lines). I'm wondering if there is any equivalent in C++.

For the following code, I could write the long string in a single line
with "\n" in the middle, or I could use multiple cout and endl. But I
just feel more readable if I can have the whole paragraph as a string.

Thanks,
Peng

#include <iostream>

int main() {
std::cout << "a long long long long long
long long long long long long string" << std::endl;
}

Oct 19 '07 #1
2 7238
On Oct 19, 3:11 pm, "PengYu...@gmail.com" <PengYu...@gmail.comwrote:
Hi,

For the following code, I could write the long string in a single line
with "\n" in the middle, or I could use multiple cout and endl. But I
just feel more readable if I can have the whole paragraph as a string.

Thanks,
Peng

#include <iostream>

int main() {
std::cout << "a long long long long long
long long long long long long string" << std::endl;
For a single ubbroken line:
std::cout << "a long long long long long"
" long long long long long long string" << std::endl;
For a split line (which is what you're asking for):
std::cout << "a long long long long long\n"
" long long long long long long string" << std::endl;

iow you can put multiple string literals together and
the compiler will concatenate them.
Not quite as elegant as you want but hey-ho.


Oct 19 '07 #2
On 2007-10-19 16:11, Pe*******@gmail.com wrote:
Hi,

In python, triple quote (""") can be used to quote a paragraph
(multiple lines). I'm wondering if there is any equivalent in C++.

For the following code, I could write the long string in a single line
with "\n" in the middle, or I could use multiple cout and endl. But I
just feel more readable if I can have the whole paragraph as a string.

Thanks,
Peng

#include <iostream>

int main() {
std::cout << "a long long long long long
long long long long long long string" << std::endl;
}

Two string literals in a row are concatenated into one string literal:

int main()
{
std::cout << "bla bla bla bla bla bla bla bla bla bla bla bla bla bla"
" bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla"
" bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla";
}

For explicit linebreaks you still need to use \n.

--
Erik Wikström
Oct 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nakamura | last post by:
Hi all, Say, I have a very long integer constant , how can I split across lines ? I tried something like MODULUS = 7567567567567567567567567567567\ 7567507546546986094860986094860\...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
4
by: Brent | last post by:
I'd like to think that my code* is pretty simple, but I'm running into memory errors when loading larger documents. The URL you see below in the first line of the Page_Load function is about 3...
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
28
by: Materialised | last post by:
Hi all, Just wondering if someone could help me with this little problem I'm having. I have a string value (it actually represents a barcode) which looks like this: 5021378002392 What I...
73
by: Yevgen Muntyan | last post by:
Hey, I was reading C99 Rationale, and it has the following two QUIET CHANGE paragraphs: 6.5.3.4: "With the introduction of the long long and extended integer types, the sizeof operator may...
4
by: BA | last post by:
Hello, I have a very strange code behavior that I cannot make heads or tails of: I have c# code being executed in BizTalk assemblies which is acting very strangely. In my BizTalk process I...
6
by: huohaodian | last post by:
Hi, How can I define a long string variable in C# with multiple lines ? For example private string longName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ...
2
by: Jean-Paul Calderone | last post by:
On Fri, 5 Sep 2008 14:24:16 -0500, Robert Dailey <rcdailey@gmail.comwrote: mystring = ( "This is a very long string that " "spans multiple lines and does " "not include line breaks or tabs "...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.