Another question

Reply

Join Date: Oct 2008
Posts: 19
Reputation: imput1234 is an unknown quantity at this point 
Solved Threads: 0
imput1234 imput1234 is offline Offline
Newbie Poster

Another question

 
0
  #1
Nov 22nd, 2008
How do I set a fixed number of places.

for example

I want 1 to be 01.

this is what I've been trying, but never works for some reason. Does anyone know how to do this. Thanks.

int i = 1;
cout << setprecision(2) << 1 ;
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,671
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 261
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Another question

 
0
  #2
Nov 22nd, 2008
I'd try using strings or develop an internal representation using ints, but a display format that is right justified and filled to left to a specified field size using zeros by using ostream manipulators.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 19
Reputation: imput1234 is an unknown quantity at this point 
Solved Threads: 0
imput1234 imput1234 is offline Offline
Newbie Poster

Re: Another question

 
0
  #3
Nov 22nd, 2008
that was just an example, the program actually displays 100's of numbers.
the only manipulator I can think of is setw

but I dont want to repeat it several times.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,671
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 261
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Another question

 
0
  #4
Nov 22nd, 2008
Welcome to the tedium that can be found in C++. This particular feeling is particularly prevalent with formatted output.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 19
Reputation: imput1234 is an unknown quantity at this point 
Solved Threads: 0
imput1234 imput1234 is offline Offline
Newbie Poster

Re: Another question

 
0
  #5
Nov 23rd, 2008
ok, so does anyone how I can fix this?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC