Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,483 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,753 people online right now. Registration is fast and FREE... Join Now!




time functions

 
Reply to this topicStart new topic

time functions

wizzy89
24 Jan, 2008 - 01:48 PM
Post #1

New D.I.C Head
*

Joined: 24 Jan, 2008
Posts: 3


My Contributions
hello,
from this program instead of this:

CODE

int setTime(Mytime& t, int h, int m )
{

    t.hours = h;
    t.mins = m;
    return 0;
}


how can the function be written with the following comments instead of using stubs:

CODE

int setTime( Mytime& t, int h, int m );
// if valid time sets hh and mm to h and m
// and returns 0
// if invalid returns integer > 0 as error code
// error code +1 = underflow hours
// error code +2 = overflow hours
// error code +4 = underflow mins
// error code +8 = overflow mins


Thanks
User is offlineProfile CardPM
+Quote Post

wizzy89
RE: Time Functions
27 Jan, 2008 - 05:43 AM
Post #2

New D.I.C Head
*

Joined: 24 Jan, 2008
Posts: 3


My Contributions
can anyone helppp!!!
User is offlineProfile CardPM
+Quote Post

Tara200
RE: Time Functions
27 Jan, 2008 - 01:48 PM
Post #3

New D.I.C Head
*

Joined: 13 Oct, 2007
Posts: 39


My Contributions
QUOTE(wizzy89 @ 24 Jan, 2008 - 02:48 PM) *

hello,
from this program instead of this:

CODE

int setTime(Mytime& t, int h, int m )
{

    t.hours = h;
    t.mins = m;
    return 0;
}


how can the function be written with the following comments instead of using stubs:

CODE

int setTime( Mytime& t, int h, int m );
// if valid time sets hh and mm to h and m
// and returns 0
// if invalid returns integer > 0 as error code
// error code +1 = underflow hours
// error code +2 = overflow hours
// error code +4 = underflow mins
// error code +8 = overflow mins


Thanks

Hi i am coding this program also check out 'Error checking time code program' posted today. It won't be much help as mine isn't completely correct either but you are welcome to use it if it helps at all.
I have got it to print out an error code if the data input is invalid however i can only get it to do it for the input 'hours' when i add the mins
in an invalid form it ignores them. You are not in a 'Bailey' class by any chance are you???
people don't seem to be coming forward with this problem do they? anyone there??

This post has been edited by Tara200: 27 Jan, 2008 - 02:46 PM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 07:08PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month