Hello,
I have the following string:
const char plaintext[] = "Fourscore and seven years ago our \
fathers brought forth upon this continent \
a new nation, conceived in liberty, and dedicated \
to the proposition that all men are created equal.";
when i step through this the variable plain text looks like this:
Fourscore and seven years ago our fathers brought forth upon
this continent
a new nation, conceived in liberty, and dedicated
to the proposition that all men are created equal.
so when i go to print it displays as it is above...not pretty!
However if i declare plaintext in this fashion:
const char plaintext[] = "Fourscore and seven years ago our fathers
brought forth upon this continent a new nation, conceived in liberty,
and dedicated to the proposition that all men are created equal.";
(in an editor it would appear on one line) there are no gaps in
plaintext.
how can i use the line break "\" for aesthetics in the editor and not
have the spaces or how do i remove the spaces.
Also i am trying to print plaintext with no more than 60 characters
per line and no word can be broken when starting a new line.
example:
on printing the word liberty if it happens to exceed 60 characters at
the "b" then the entire word needs to be printed on the next line.
hope all this is clear.
Thanks,
Lino
Carl Daniel [VC++ MVP] - 24 Apr 2004 20:54 GMT
> Hello,
>
[quoted text clipped - 24 lines]
> how can i use the line break "\" for aesthetics in the editor and not
> have the spaces or how do i remove the spaces.
Write it like this:
const char plaintext[] =
"Fourscore and seven years ago our "
"fathers brought forth upon this continent "
"a new nation, conceived in liberty, and dedicated "
"to the proposition that all men are created equal.";
Adjacent string literals are concatenated by the compiler into a single
string with no intervening newlines.
-cd
Pavel A. - 24 Apr 2004 22:03 GMT
> Hello,
>
[quoted text clipped - 4 lines]
> a new nation, conceived in liberty, and dedicated \
> to the proposition that all men are created equal.";
The modern, standard, way to make a string to span multiple lines
does NOT use backslash. Try this:
const char plaintext[] =
"Fourscore and seven years ago our "
"fathers brought forth upon this continent "
"a new nation, conceived in liberty, and dedicated "
"to the proposition that all men are created equal.";
The max. string length limit still applies however.
--
James Sexton - 02 May 2004 08:01 GMT
An easy and economic way to do what you want to do is as follows
#define NUMBER_LINES
char * szBuffer[NUMBER_LINES]=
"Fourscore and seven years ago our"
"fathers brought forth upon this continent"
"a new nation, conceived in liberty, and dedicated"
"to the proposition that all men are created equal.
}
// The syntax is char * Buffer={"Line_0"
"Line_1"
"Line_2"
"Line_3"}
// if the buffer is outseide a function use the pointe
// if the buffer is inside a function you don't need the pointe
/
BYTE function(void
BYTE i,limit
limit = NUMBER_LINES
i=0
do
cout << szBuffer[i]
cout << " " << endl
while (++ i < limit)
return (limit)
/
// The do{}while; inserts spaces and linefeeds after each Buffer's [Line
/
// To control the number of characters you show or print/line you coul
// use the same routine. But you would have to read from each line th
// number of characters you want to show or print into another buffe
// and then show of print this new buffer. This would call for some strin
// manipulation. Easier, would be to arrange your text from the start to
// the number of characters you want to print or show/line
James Sexto