|
-
Aug 24th, 2001, 07:45 PM
#1
Thread Starter
Addicted Member
Get # of sec since midnight
I am using Win 98 with Microsof Visual C++ 6.0. How can I get the number of seconds since midnight?
BTW, Thanks for all your help
Member of the anti-gay cross-dressing trans-species wolves alliance.
-
Aug 24th, 2001, 10:38 PM
#2
Frenzied Member
-
Aug 25th, 2001, 06:09 AM
#3
Frenzied Member
Well it is not a huge number as you say because in 24 hrs there are 86400 seconds, and that can easily be put into an integer.
-
Aug 25th, 2001, 10:40 AM
#4
Thread Starter
Addicted Member
Hey i'm new to C++. BTW, this is a console program. How do I do it?
BTW, Thanks for all your help
Member of the anti-gay cross-dressing trans-species wolves alliance.
-
Aug 25th, 2001, 11:28 AM
#5
Lively Member
Even though you're using console, you can still use the Win32 API (as long as its a Win32 Console, and not a DOS program).
Just include windows.h> and use whatever you want
-
Aug 25th, 2001, 04:28 PM
#6
Frenzied Member
Well I'm saying it would be huge compared the the total...since there were only a few minutes left in the day...btw how do you use time.h? This thread got me interrested in doing this but I keep getting the same #
-
Aug 25th, 2001, 07:12 PM
#7
Originally posted by Vlatko
Well it is not a huge number as you say because in 24 hrs there are 86400 seconds, and that can easily be put into an integer.
It would have to be in a long, rather than an int, because the int (unsigned) can only store up to 65535.
-
Aug 25th, 2001, 08:09 PM
#8
Here's code that works....
PHP Code:
#include <windows.h>
#include <stdio.h>
void main(void){
long elapsed =0;
// Create system time structure
SYSTEMTIME *SystemTime, Sys;
SystemTime = &Sys;
GetLocalTime(SystemTime);
elapsed = SystemTime->wSecond;
elapsed += (SystemTime->wMinute * 60);
elapsed += (SystemTime->wHour * 3600);
printf("Secs since midnight %d\n",elapsed);
}
-
Aug 26th, 2001, 05:57 AM
#9
Frenzied Member
Megatron integers are 4 butes long in C++ so an integer can hold values from –2,147,483,648 to 2,147,483,647. Long is also an integer (long integer) but it has the same range as an integer.
Unsigned short int can hold values up to 65535 not just an integer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|