Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Truncating integer

Thread Tools

Truncating integer

Posts: n/a
Is there a simple way to drop numbers from integer value with string
formatting? Here's my problem:

int year = 2008;
printf("%02d", year);

It now prints "2008", but I would like it to print just "08". I could
subtract 2000 from the orginal value but I was wondering whether there's
another, more beutiful way to solve this.
Reply With Quote

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
truncating java 'doubles' BemusedByQM Java 2 07-25-2005 01:17 PM
Truncating Variables Jason Williard ASP .Net 11 10-18-2004 01:27 PM
System.web.mail truncating message body - strange behaviour ?? Jitesh Sinha ASP .Net 1 12-05-2003 03:04 PM
JavaService append mode instead of truncating log file uy_do Java 1 12-04-2003 02:42 AM
Truncating char array qazmlp C Programming 4 07-28-2003 08:25 AM