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 3 2822
lino wrote: 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.
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
"lino" <li********@sbc global-dot-net.no-spam.invalid> wrote in message news:40******** **@127.0.0.1... 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.";
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.
--
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hokiegal99 |
last post by:
This script works as I expect, except for the last section. I want the
last section to actually remove all spaces from the front and/or end of
filenames. For example, a file that was named " test " would be
renamed "test" (the 2 spaces before and after the filename removed). Any
suggestions on how to do this?
import os, re, string
print " "
print "--- Remove '%2f' From Filenames ---"
print " "
|
by: jalkadir |
last post by:
I am trying to find a way to remove the leading and tailing blanks from
a string.
What I have come up with is not doing the work as I expected; because
if the value I pass to the function is " string " the leading and
trailing blanks are not removed. What am I doing wrong?
trimIt( std::string s ) {
size_t offset = s.length();
// Trim leading spaces ???
s.erase( 0, s.find_first_not_of( "\t\n" ) );
|
by: gopal srinivasan |
last post by:
Hi,
I have a text like this -
"This is a message containing tabs and white spaces"
Now this text contains tabs and white spaces. I want remove the tabs
and white spaces(if it more than once between two words).
Is there any function we have in C which will find out the tabs and
white spaces and returns the text in the follwong way -
|
by: Magix |
last post by:
Hi,
Everytime I received a fix-length of string, let say 15 (the unused portion
will filled with Spaces before receive), I want to remove the Spaces from
END until I encounter a non-space char.
let say: testBuf is the buffer that receive this fix-length string.
printf("",testBuf);
Output:
|
by: Mike in Paradise |
last post by:
Is there a more effcient way of removing the spaces from the names for a
Enumerated value that has several values when you split it)???
When you do a toString it puts ,<SPACE> between the entries
eg. category.ToString() = "cat1, cat2, cat3"
What I am currently doing..(and I use this a lot..)
this.categoriesEntry.Items.AddRange(
| |
by: starsky51 |
last post by:
I'm sure it's something i'm doing wrong, I just can't see it.
I've set up a simple page with the following code:
<html>
<head>
<title>tester</title>
<script language="javascript" type="text/javascript">
alert('First String Second String');
</script>
</head>
|
by: beatTheDevil |
last post by:
Hey guys,
As the title says I'm trying to make a regular expression (regex/regexp) for use in removing the comments from code. In this case, this particular regex is meant to match /* ... */ comments.
I'm using Ruby v.1.8.6
Here's my regex:
multiline_comments = /\/\*(.*?)\*\//
When I try
myStr.gsub(multiline_comments, "")
|
by: ramu |
last post by:
Hi,
Suppose I have a string like this:
"I have a string \"and a inner string\\\" I want to remove space in
this string but not in the inner string"
In the above string I have to remove spaces, but not in the inner
string(\"and a inner string\\\"). Will anyone please tell me how to do
this?
|
by: code green |
last post by:
I am trying to write a simple function that will take a string containing an
address line or business name and return it nicely formatted.
By this I mean extra spaces removed and words capitalised.
I also wish it to be legal XML..
The result string is further sent to another function to check
the names and addresses don't appear on a blacklist
which is why the extra spaces need removing.
This is my test function so far
function...
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |