C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 23rd, 2005, 03:49 AM
shaer shaer is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 shaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation if y=0192 how to print y=0192 by fixing int y to 4 digits..?

hi all..i'm having a problem regarding c++ .
The problem is I need an integer of 4 digits

0000=<y=<9999
let y= 0192
but when i take cout<< y
it gives me 192 only..
but i need to print y = 0192 how can i fix the digits of an integer number?

urgently needed..
thankz..
regards
shaer

Reply With Quote
  #2  
Old January 24th, 2005, 08:30 AM
marmo marmo is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 37 marmo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 20 sec
Reputation Power: 4
Search google for info on the iomanip and conio libraries.

Reply With Quote
  #3  
Old February 1st, 2005, 11:01 PM
jessefromsouth jessefromsouth is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 jessefromsouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 55 sec
Reputation Power: 0
Cool Formatting output with iostream

#include <iostream>
#include <iomanip>
int num = 603;
cout<<setiosflags(ios_base::right);
cout<<setfill('0')<<setw(4)<<num;

try this out...hope its what your looking for.
-jesse


Quote:
Originally Posted by shaer
hi all..i'm having a problem regarding c++ .
The problem is I need an integer of 4 digits

0000=<y=<9999
let y= 0192
but when i take cout<< y
it gives me 192 only..
but i need to print y = 0192 how can i fix the digits of an integer number?

urgently needed..
thankz..
regards
shaer

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > if y=0192 how to print y=0192 by fixing int y to 4 digits..?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway