473,803 Members | 2,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inline text, large strings

Hi,
I want to fill a string like this:

using namespace std;
string text="
now a lot of text ............... .
now a lot of text ............... .
now a lot of text ............... .
now a lot of text ............... .
now a lot of text ............... .
";

I get the warning message using g++ (GCC) 3.2.2 on linux:
.......warning: multi-line string literals are deprecated

Is there a way to write large portions of text right into the
code without getting these warnings?
I do not want to write something like this:

string text;
text+="now a lot of text ............... .";
text+="now a lot of text ............... .";
text+="now a lot of text ............... .";
text+="now a lot of text ............... .";
text+="now a lot of text ............... .";

-- thanks, daniel

Jul 22 '05
13 4345
> The '\' is only to indicate the compiler, that the next line is
extending this line (as in the #define macros)


....which the OP didn't use. My fault, sorry for not looking exaclty.
Flame me, I'm unworthy to post here....
Jul 22 '05 #11
"Gernot Frisch" <Me@Privacy.net > wrote:
The original text:
char as[]="asasd
asdasd
asdasd";
had _no_ newline characters.


Since multi-line string constants are not defined in standard C++, it is
somewhat hard to tell what the standard semantics of the above string are.
I guess that there are at least three cases how the above string is
treated by different systems:
- it is an error
- it is a string with newlines
- it is a string without newline
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting
Jul 22 '05 #12
On Tue, 17 Aug 2004 15:04:16 +0200, "Gernot Frisch" <Me@Privacy.net >
wrote in comp.lang.c++:
"now " "a " "lot " "of " "text"

is equivalent to "now a lot of text".
In other words: The compiler will catanate individual string
literals into one literal on its own.


Crap! 5 years of programming things like:

printf(" Here\n\
comes \
my \
text");
and now you tell me I can add comments and indentination with "" ""...
Bohooo.. All my pretty source code looks like a piece of #*%& because
I didn't know that.
-Gernot


Yes, since the very first 1989 ANSI C standard.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 22 '05 #13

"Dietmar Kuehl" <di***********@ yahoo.com> schrieb im Newsbeitrag
news:5b******** *************** ***@posting.goo gle.com...
"Gernot Frisch" <Me@Privacy.net > wrote:
The original text:
char as[]="asasd
asdasd
asdasd";
had _no_ newline characters.
Since multi-line string constants are not defined in standard C++,

it is somewhat hard to tell what the standard semantics of the above string are. I guess that there are at least three cases how the above string is
treated by different systems:
- it is an error
- it is a string with newlines
- it is a string without newline


Re-checked it: VC gives an error, gcc will add a newline.
Jul 22 '05 #14

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

Similar topics

4
3159
by: FLEB | last post by:
I like PHP for its excellent inline integration into standard HTML files, but I like Perl for its quick-moving syntax and simpler data-processing. To resolve this deep-seated inner turmoil (oh, the drama) I've been trying to think of good ways to get Perl code to run inline in a PHP script. Here are a few of my ideas. If anyone has any further ideas, resources, or knows of someone else who's solved this already, please do tell... 1.) The...
6
19470
by: Ratnakar Pedagani | last post by:
Hi, I'm trying to parse the text file, which is of size more than 2mb. I'm using the following sample code Open "c:\sim1.txt" For Input As #1 Do While Not EOF(1) Input #1, Data If (InStr(Data, "Summary")) Then
7
7116
by: Danny | last post by:
I have a small <div> element which contains two text blocks - one within <h5> tags and the other within <p> tags. I don't want any extra line spacing between elements so use the display:inline property. This works for IE6 but Opera7.54 and Netscape7.1 add large line spacing between the text blocks and any lines of wrapped text. The line spacing is independant of the font size and is consistent between all lines. ie: it's not larger...
43
13308
by: Patrick Laurent | last post by:
Hello I have a program with many many inlined template functions It is essential for the execution speed that every (or almost every) function marked as inlined, becomes really inlined by the compiler. I already compiled the program with Intel Compiler (ICL) on Visual C++, and it works fine and fast. I verified that the functions are really inlined. But with GCC 3.4 (Linux+Cygwin) or ICC (Linux), The same program is about 5
3
367
by: junky_fellow | last post by:
What is an inline function ? When should we declare a particular function as inline ? If a function is declared to be inline, does that mean that the entire code for that function is subtituted there just like macros ? Then why not use macros ?
3
14328
by: i_dvlp | last post by:
I'm trying to replicate a fancy drop-down control (MS-egads!) with form <select><option> It doesn't look like you can specity width as an attribute or define width with CSS. It looks like my choices are to use smaller fonts or choose shorter option strings. inline: I want to put a small graphic immediately to the right of the select.
5
1883
by: soup_nazi | last post by:
I want to remove duplicate entries within a text file. So if I had this within a text file... Applications/Diabetic Registry/ Applications/Diabetic Registry/ Applications/Diabetic Registry/ Applications/Great Plains/ Applications/Great Plains/ Applications/Great Plains/ Applications/Great Plains/Servers/
7
16132
by: Wu Shaohua | last post by:
Hi Guys, 1. As we know usually we should not define a constructor as inline. I also learned if we define a member function inside the class this member function will be automatically be inline'ed. My question is: If I define a constructor (including its body) or another large member function inside the class, the constructor or the member function is inline or not? why? 2. I learned that if the member function is big we should not...
3
2473
by: news.inode.at | last post by:
Sorry for this stupid question, but i am lost. If i write an stringlib with += overload operators (no i do not, but my thing is much more complicated) , and i have to precalculate the strlen() -- as seen in the example here How do i solve this ? struct myStr { private: unsigned len;
0
9566
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7607
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.