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

how to print blank space(s) ?..

how to print, say 50 blank spaces, or say 20 blank spaces ?

I wanted use such blank spaces that can be output in a program at
predetermined places when printing with "cout".
Jul 22 '05 #1
5 48200
"mark" <ma*********@yahoo.com> wrote...
how to print, say 50 blank spaces, or say 20 blank spaces ?

I wanted use such blank spaces that can be output in a program at
predetermined places when printing with "cout".


Use a loop

for (int i = 0; i < 50; ...

and output one space at a time

Or, declare a constant string consisting of 50 spaces and
output it.

Or, declare a constant string consisting of 5 spaces and
output it in a loop that executes 10 times.

Or, declare a constant string consisting of 10 spaces and
output it in a loop that executes 5 times.

Or, ...

Victor
Jul 22 '05 #2
On Wed, 16 Jun 2004 18:56:39 -0700, mark wrote:
how to print, say 50 blank spaces, or say 20 blank spaces ?

I wanted use such blank spaces that can be output in a program at
predetermined places when printing with "cout".


What are you really trying to accomplish? If you want aligned output,
look into the setw family of operations on ostreams. If you really want
to output any value more than once, loop.

--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.

Jul 22 '05 #3
On Thu, 17 Jun 2004 04:05:28 +0000, Victor Bazarov wrote:
"mark" <ma*********@yahoo.com> wrote...
how to print, say 50 blank spaces, or say 20 blank spaces ?

I wanted use such blank spaces that can be output in a program at
predetermined places when printing with "cout".


Use a loop

for (int i = 0; i < 50; ...

and output one space at a time

Or, declare a constant string consisting of 50 spaces and
output it.

Or, declare a constant string consisting of 5 spaces and
output it in a loop that executes 10 times.

Or, declare a constant string consisting of 10 spaces and
output it in a loop that executes 5 times.

Or, ...

Victor


int main(void){
int increment;

for(increment = 1; increment <= 50; increment++){
if(!(50 % increment)){
printf("Or, declare a constant string \
consisting of %i spaces and\noutput it in a loop that executes %i \
times.\n\n", increment, 50 / increment);
}
}
return 0;
}

/***
Yes, yes this is a joke.
***/
Jul 22 '05 #4
On 16 Jun 2004 18:56:39 -0700 in comp.lang.c++, ma*********@yahoo.com (mark) wrote,
how to print, say 50 blank spaces, or say 20 blank spaces ?


cout << setw(50) << " ";

Jul 22 '05 #5

"mark" <ma*********@yahoo.com> wrote in message
news:5e**************************@posting.google.c om...
how to print, say 50 blank spaces, or say 20 blank spaces ?
std::cout << std::string(50, ' ');

std::cout << std::string(20, ' ');

I wanted use such blank spaces that can be output in a program at
predetermined places when printing with "cout".


The only way you can 'predetermine' where the output goes
is to keep track of how many characters you've printed
so far on each line. There is no way to specify a
vertical position to print on a video device. I/O in
C++ is only in terms of 'streams of characters'.
-Mike
Jul 22 '05 #6

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

Similar topics

3
by: Buz | last post by:
I am having a problem with extra, unwanted space showing up on my web form tables. I've tried hand coding and can get the htm file to display fine. But as soon as I bring the form into Visual...
2
by: barb28 | last post by:
Hello, sometimes I have noticed that in web addresses, the number: 20% will show up in the address. I think this is somehow related to a 'blank space', but am unsure, does anyone know about...
0
by: Penguin | last post by:
Using Access 97, I've created a grading sheet. To save space, the subjects are in vertical columns on a sub-report, like so: Math Spelling Reading N C T A A E U A I ...
2
by: Amir | last post by:
I really hope someone can explain this behavior. I have spend quite a bit of time and tried a bunch of things, so far nothing has worked. I have a page on which I have a datagrid with template...
2
by: Bill Nguyen | last post by:
I tried in vain to add blank space to the end of couple variables as below: mPadding = Convert.ToChar(" ") mdriverBegin.PadRight(16, mPadding) mdriverEnd.PadRight(16, mPadding) ...
7
by: 一首诗 | last post by:
Is there any simple way to solve this problem?
1
by: monica4rdecos | last post by:
Hi, I am developing a website. Its width is fixed and is 1000px. I want to avoid horizontal scroll bar in a standard 1024 X 768 browser. So i fixed it as 1024px width. But in firefox a blank...
0
by: Tessy Mithu | last post by:
Am trying to print a receipt from VB6.0 with MS.Access as db. While generating the data report iam getting blank spaces between detailed section and Bottom margin of the report. Required to know is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.