Formatting problem with dates.

This is a discussion on Formatting problem with dates. within the C++ Programming forums, part of the General Programming Boards category; Got a program were user enters month, day, and year(19XX). Suppose to display 01/01/01 format with zeros in front of ...

  1. #1
    Unregistered
    Guest

    Smile Formatting problem with dates.

    Got a program were user enters month, day, and year(19XX).

    Suppose to display 01/01/01 format with zeros in front of the single digit days and months; and years that have zero as 3rd digit (2001, 1909).

    Only display it as 1/1/1 right now.

    Thanks for any input.

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    something along these lines should do it....

    cout<< ((Day<10) ? "0":"") << Day;

    etc.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Unregistered
    Guest

    Smile It worked. Thanks so much..........

    and I learned something.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  3. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  4. problem formatting
    By PJYelton in forum C++ Programming
    Replies: 5
    Last Post: 11-07-2002, 08:06 PM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21