input problems

Discussion in 'C' started by musicmancanora4, Mar 16, 2006.

  1. musicmancanora4

    musicmancanora4 New Member

    Joined:
    Mar 9, 2006
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    0
    Hi guys im having a big issue with my program iv attached the pogram because iv recieved all sorts of stuff of what the problem could be.

    if you take a look at the source code of cal.c im calling the getUserInput function then calling another function called validate month to validate the input from the getUserInput function..

    However its not validating any of the input correctly at all and im 100 % sure there's nothing wrong with my validation coding..

    So when i type a month between 0 - 12 i still get an error saying that its an incorrect month when it shouldnt be.. 0 is valid because thats suppose to display all months..

    Its sorta difficult to explain if someone could run the program and test the conditionals in the validation function you will see what i mean..

    im going nuts someone plz solve it thnxs
     

    Attached Files:

  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Just find the following lines in cal.c in the function unsigned getMonth()
    Code:
    month = getUserInput(prompt);
    month = validateMonth(prompt,month );
    
    and replace it with the following lines
    Code:
    month = getUserInput(prompt);
    valMonth = atoi(month);
    month = validateMonth(valMonth,prompt);
    This should solve your problem of prompt.

    Thanks
    Shabbir
     
  3. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    39
    Trophy Points:
    28
    That what I was explaining to him in [thread=638]do while prob on validation[/thread] thread
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice