# How to place a space in the cout line for 3 different numbers?

Page 1 of 1

## 2 Replies - 26642 Views - Last Post: 01 February 2008 - 10:37 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=42266&amp;s=396f825a700e9fceab5e433842b4b667&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 RoverTCV8

Reputation: 0
• Posts: 14
• Joined: 01-February 08

# How to place a space in the cout line for 3 different numbers?

Posted 01 February 2008 - 10:15 PM

Hello,
I am new to this as this is my new experience with C++. I have written about a 75 lines of code and is fine howeever, after my "double line,
I have this:

cout << "Input three different numbers: \b";

What I need to know is how to get 3 numbers to post on the same line with a space between them?
Thanks
David
Is This A Good Question/Topic? 0

## Replies To: How to place a space in the cout line for 3 different numbers?

### #2 Martyr2

• Programming Theoretician

Reputation: 4860
• Posts: 13,176
• Joined: 18-April 07

## Re: How to place a space in the cout line for 3 different numbers?

Posted 01 February 2008 - 10:33 PM

Well if you are asking the user to input the numbers, they are the one that has to add the spaces. If you just want to add spaces between numbers, you can simply use " " (that is double quotes with a space in the middle).

```cout << "Input three numbers: " << number1 << " " << number2 << " " << number3 << endl;

```

This would print three numbers contained in the three variables onto the line. But if you are asking for them to input the numbers, the user has to do that and you have to parse their response to fetch the three numbers.

I hope that makes sense and that I am understanding you correctly.

### #3 Jingle

• D.I.C Regular

Reputation: 9
• Posts: 320
• Joined: 20-October 07

## Re: How to place a space in the cout line for 3 different numbers?

Posted 01 February 2008 - 10:37 PM

RoverTCV8, on 1 Feb, 2008 - 10:15 PM, said:

Hello,
I am new to this as this is my new experience with C++. I have written about a 75 lines of code and is fine howeever, after my "double line,
I have this:

cout << "Input three different numbers: \b";

What I need to know is how to get 3 numbers to post on the same line with a space between them?
Thanks
David

do you mean that you want to print 3 numbers on the same line but with spaces between them?
or that you want spaces on the cin>> while your typing it in.

the first is easy there are multiple ways of doing it the latter is not so easy and i have no clue how it would be done.

cout<<2<<' '<<3<<' '<<4;
that is one way of doing it.

looks like Martyr beat me to it

This post has been edited by Jingle: 02 February 2008 - 06:12 PM