6 Replies - 513 Views - Last Post: 06 January 2012 - 07:39 AM Rate Topic: -----

#1 drksilent  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-January 12

Question about line of code with cout and setw

Posted 05 January 2012 - 07:31 AM

What does
 cout<<setw(9)<<element<<setw(9)<<*elementPtr<<setw(15)<<elementPtr<< “\n”;  

This post has been edited by jimblumberg: 05 January 2012 - 07:43 AM
Reason for edit:: Fixed Code tags.

Is This A Good Question/Topic? 0
  • +

Replies To: Question about line of code with cout and setw

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 3988
  • View blog
  • Posts: 12,301
  • Joined: 25-December 09

Re: Question about line of code with cout and setw

Posted 05 January 2012 - 07:44 AM

What do you think it does? Ask specific questions.

Jim
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6035
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: Question about line of code with cout and setw

Posted 05 January 2012 - 08:06 AM

This is your second post with a topic that is meaningless. We KNOW you have a C++ Coding Question, or you wouldn't have posted a question in the C++ FORUM!

Please use a title that describes a little about your question, like that to which I've changed yours.
Was This Post Helpful? 0
  • +
  • -

#4 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 995
  • Joined: 30-July 08

Re: Question about line of code with cout and setw

Posted 05 January 2012 - 08:20 AM

Best way to find out... if you don't wanna read anything.
1. Open your compiler
2. Add needed header files
3. add all needed for the code to compile
4. compile and read the output.

If you don't understand the line, open your books index (usually in the end of the book) and look up "cout", "setw", "variable" and "pointer" and read what they are about.
Was This Post Helpful? 2
  • +
  • -

#5 LordVicus  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 57
  • Joined: 05-November 09

Re: Question about line of code with cout and setw

Posted 05 January 2012 - 04:11 PM

Google setw() and you will find a treasure trove of answers to your question.
Was This Post Helpful? 0
  • +
  • -

#6 drksilent  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 04-January 12

Re: Question about line of code with cout and setw

Posted 06 January 2012 - 07:27 AM

all I know is that it sets the width of the program to 9...I'm not sure what anything else means
Was This Post Helpful? 0
  • +
  • -

#7 jimblumberg  Icon User is offline

  • member icon


Reputation: 3988
  • View blog
  • Posts: 12,301
  • Joined: 25-December 09

Re: Question about line of code with cout and setw

Posted 06 January 2012 - 07:39 AM

You may want to start by reading this tutorial: C++ Language Tutorial, start on the first page and continue until at least the section on Basic Input and output operations. This should answer most of your questions about the posted code.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1