Thread: HELP Required C Program that output the very next date after Input a date

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    7

    Lightbulb HELP Required C Program that output the very next date after Input a date

    Problem: HELP Required Write a C Program that output the very next date after Input a date

    suppose :

    Input: (DD/MM/YYYY) 21/09/2012

    OUTPUT: 22/09/2012



    Thanks in Advance.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What have you tried?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by riyaj123 View Post
    Problem: HELP Required Write a C Program that output the very next date after Input a date

    suppose :

    Input: (DD/MM/YYYY) 21/09/2012

    OUTPUT: 22/09/2012



    Thanks in Advance.
    Yes, you are required to write it.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  4. #4
    Registered User
    Join Date
    Mar 2012
    Posts
    7
    I try to write an algorithm first of all.. But my head goes off.. I have to submit this project in my class in 3 days. Pls help me..

  5. #5
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by riyaj123 View Post
    I try to write an algorithm first of all.. But my head goes off.. I have to submit this project in my class in 3 days. Pls help me..
    This is not a homework service. You provide some code, some ideas and we critique it and point you in the correct direction. No effort from you, no effort from us. We have all done our own homework and we don't intend to do the one assigned to others.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  6. #6
    Registered User
    Join Date
    Mar 2012
    Posts
    7
    Let me try it myself. Thanks..
    Last edited by riyaj123; 03-27-2012 at 09:57 AM.

  7. #7
    Registered User
    Join Date
    Mar 2012
    Posts
    7
    God save me. '
    Last edited by riyaj123; 03-27-2012 at 09:57 AM.

  8. #8
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Someone should erase the above. Who knows what it says?
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    How about starting with the basics?

    Code:
    int day, month, year;
    // some stuff to prompt for, and read input, and store in the appropriate variables.
    
    printf("Day=%d\n", day );
    printf("Month=%d\n", month );
    printf("Year=%d\n", year );
    Until that works reliably, there isn't much point in considering the next step.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Registered User
    Join Date
    Mar 2012
    Posts
    7
    help me. Pls anyone pls get me the code.

  11. #11
    Registered User
    Join Date
    Mar 2012
    Posts
    7
    help me. Pls anyone pls get me the code.

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    No.

    *thread closed*
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Date Program Help!!
    By LatinoHeat in forum C++ Programming
    Replies: 2
    Last Post: 02-06-2011, 08:35 PM
  2. Two date objects showing same date?
    By dxfoo in forum C++ Programming
    Replies: 7
    Last Post: 06-17-2010, 06:06 PM
  3. Review required for program of date difference
    By chottachatri in forum C Programming
    Replies: 6
    Last Post: 10-31-2008, 11:46 AM
  4. Output Text File Name by Today's Date
    By jbayne in forum C++ Programming
    Replies: 1
    Last Post: 07-09-2007, 08:09 AM
  5. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM