I want to create my own time stamp data structure in C.
DAY ( 0 – 30 ), HOUR ( 0 – 23 ), MINUTE ( 0 – 59 )
What is the smallest data structure possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, you could pack it all in an
unsigned short(That’s 2 bytes, 5 bits for Day, 5 bits for hour, 6 bits for minute)… and use some shifts and masking to get the values.or using macros
(You didn’t mention month/year in your current version of the question, so I’ve omitted them).
[Edit: use
unsigned short– not signedshort.]