473,508 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i want to adjust the spacing entered, but...

10 New Member
If you type a string:

"It's good."

there's one space between the two words.

but how can i adjust the string to two spaces or more.

"it's good."
Apr 5 '07 #1
3 1344
WuJianWei
10 New Member
cout<<"\n----------------------------------------------------------------"
<<"\n3. Adjust the spacing of the input string with a given number.\n"
<<"----------------------------------------------------------------\n"
<<"\n- Please enter the spacing: ";
int space=1;
cin>>space;

cin.getline(string,150,'\n');
cout<<"\n- Please enter a string of length < 70:\n";
cin.getline(string,150,'\n');

int i=0;
for( char *s = string ; *s!='\0' ; s++, i++ );

while( i>=70 )
{
cout<<"\n- The input string is too long. Please reenter a string of length < 70:\n";
cin.getline(string,150);
i=0;
for( char *s = string ; *s!='\0' ; s++, i++ );
}

static int x=0;
int z=space;
while(string[x]!='\0')
{
for(;string[x]!=' ';x++)
cout<<string[x];

for(;space>0;space--)
cout<<' ';
x++;
space=z;
}
cout<<string<<endl<<endl;

The output is always with something undesirable. Who can help me to debug?
Apr 5 '07 #2
Indianraja
22 New Member
If you type a string:

"It's good."

there's one space between the two words.

but how can i adjust the string to two spaces or more.

"it's good."

get the ascii value of spacebar and then set the command if it's cliked then set how many spaces u want..... k... if u do lik this when ever u press the spacebar it give the no of spaces as u set....
Apr 5 '07 #3
sicarie
4,677 Recognized Expert Moderator Specialist
WuJianWei-

I have merged these threads as you asked the same question. Please read our Posting Guidelines and abide by them as you agreed to when you joined this community. This includes not double-posting, and using code tags around your code.

I realize one question was asked well before the other. In cases like that, if you think we have forgotten about your code, after 24 hours, you can reply to your original post with a "bump" message, this will move it back to the top of the forum.

If you're looking to just add whitespace, I would recommend looking into strtok(). You can use it to pick apart a string at a certain delimiter, and then then use something like strcat() or strcpy() to add the desired number of spaces.
Apr 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3438
by: Hal Vaughan | last post by:
I'm testing a GUI app on a couple Linux boxen and one Win2k box. I'm using Java 1.4.2 on each (or the closest on Win2k -- whatever version comes close). On one Linux box and the Win2k box the...
2
1505
by: Ding Lei | last post by:
Hello folks, I am using xml for a newsletter, along with a xsl file to display it in a browser. In the xml file, a newline, tab or whitespace character all causes exactly one spacing between two...
12
39084
by: Rick DeBay | last post by:
I'm trying to create a layout table, where the spacing between rows varies. I've tried using setting margin-top and border-top for the rows I wan't spaced down from the one above, and I've also...
5
2968
by: Andrew Poulos | last post by:
If I have a text INPUT within a block of text how do I 'correct' for the line spacing. The line spacing above and below the INPUT is larger than the line spacing generally: <div...
12
2190
by: Sebastien B. | last post by:
I'm wondering if it's at all possible to have spacing between a table's cells, and only between the cells, not between the outter cells and the table's border. See end of message for an example...
4
2451
by: metoikos | last post by:
I've scoured the web (clumsily, I'm sure) for information on the difficulties I am having, checked my markup in validators, and had a friend with more CSS clue look over it, but I haven't had any...
10
11020
by: phil-news-nospam | last post by:
I have a table with 3 columns in 1 row. I want to increase the spacing _between_ the columns (gutter) _without_ increasing the spacing between those columns and the table itself. Is there a way...
1
3278
by: replyrpatil | last post by:
What I am trying to do: I need to print a compact access report (font 6 size) created using RTF2 program developed by Stephen Lebans to generate a TIF image of custom size (5.5 in x 2.0 in) ...
4
2187
by: Mamluk Caliph | last post by:
For quite some time I've used code as the following to be able to "cut&paste" parts from different headerfiles of the same name. It has worked with GCC, MS, Borland, Keil to name a few. In...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
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...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4720
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...
0
3211
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...
0
1568
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 ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
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...

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.