473,396 Members | 1,891 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,396 software developers and data experts.

String of Spaces

Hi,

I am very much a newbie in c++ and would appreciate feedback on the
following.
Due to known bug with setw() iomanipulator such that it only works
against numeric output , I need to create strings of spaces of varying
sizes.

Is there a function to do this or any easy way to detrive ?

Thanking you in advance

Puvendran
Jul 19 '05 #1
3 2198

"Puvendran" <pu*******************@btfinancialgroup.com> wrote in message
news:d5*************************@posting.google.co m...
Hi,

I am very much a newbie in c++ and would appreciate feedback on the
following.
Due to known bug with setw() iomanipulator such that it only works
against numeric output , I need to create strings of spaces of varying
sizes.

Is there a function to do this or any easy way to detrive ?


std::string(how_many, ' ');

-Mike
Jul 19 '05 #2
Puvendran wrote in news:d5*************************@posting.google.co m:
Hi,

I am very much a newbie in c++ and would appreciate feedback on the
following.
Due to known bug with setw() iomanipulator such that it only works
against numeric output , I need to create strings of spaces of varying
sizes.

Is there a function to do this or any easy way to detrive ?


#include <iostream>
#include <string>

int main()
{
std::cerr << "[" << std::string( 10, ' ' ) << "]\n";
}

HTH

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 19 '05 #3
Rob Williscroft <rt*@freenet.REMOVE.co.uk> wrote in message news:<Xn**********************************@195.129 .110.130>...
Puvendran wrote in news:d5*************************@posting.google.co m:
Hi,

I am very much a newbie in c++ and would appreciate feedback on the
following.
Due to known bug with setw() iomanipulator such that it only works
against numeric output , I need to create strings of spaces of varying
sizes.

Is there a function to do this or any easy way to detrive ?


#include <iostream>
#include <string>

int main()
{
std::cerr << "[" << std::string( 10, ' ' ) << "]\n";
}

HTH

Rob.


Thanks for the feedback.

One thing I needed to be aware of was if you pass 0 for the length
program does not work as expected.
Jul 19 '05 #4

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

Similar topics

9
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
16
by: Steve | last post by:
Hi Guys, I have a string which contains data elements separated by spaces. I also have a function which returns the number of characters from the beginning of the string for a given number of...
18
by: JKop | last post by:
Can some-one please point me to a nice site that gives an exhaustive list of all the memberfunctions, membervariables, operators, etc. of the std::string class, along with an informative...
9
by: Durgesh Sharma | last post by:
Hi All, Pleas help me .I am a starter as far as C Language is concerned . How can i Right Trim all the white spaces of a very long (2000 chars) Charecter string ( from the Right Side ) ? or how...
20
by: Chris LaJoie | last post by:
I'm looking for some kind of simple string compression code I can use. I'm not looking for SharpZipLib. Their implimentation spans several classes and is very complex. I'm just looking for...
16
by: Charles Law | last post by:
I have a string similar to the following: " MyString 40 "Hello world" all " It contains white space that may be spaces or tabs, or a combination, and I want to produce an array...
15
by: DanielJohnson | last post by:
I am writing a program in which I am removing all the spaces from the string. I thought that I could do it two ways. One was parsing the string character by character and copying onto another...
11
by: xyz | last post by:
I have a string 16:23:18.659343 131.188.37.230.22 131.188.37.59.1398 tcp 168 for example lets say for the above string 16:23:18.659343 -- time 131.188.37.230 -- srcaddress 22 ...
121
by: swengineer001 | last post by:
Just looking for a few eyes on this code other than my own. void TrimCString(char *str) { // Trim whitespace from beginning: size_t i = 0; size_t j; while(isspace(str)) {
8
by: drjay1627 | last post by:
hello, This is my 1st post here! *welcome drjay* Thanks! I look answering questions and getting answers to other! Now that we got that out of the way. I'm trying to read in a string and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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,...

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.