The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
CTime returns -1
Discuss CTime returns -1 in the C Programming forum on Dev Shed. CTime returns -1 C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 14th, 2005, 10:12 AM
|
|
Contributing User
|
|
Join Date: May 2004
Posts: 105
Time spent in forums: 1 h 12 m 41 sec
Reputation Power: 10
|
|
|
CTime returns -1
Why would the following code fail?
Code:
COleDateTime t = COleDateTime::GetCurrentTime();
in this innocent code GetCurrentTime() returns -1
I have no idea why 
|

April 14th, 2005, 10:15 AM
|
 |
I'm Baaaaaaack!
|
|
Join Date: Jul 2003
Location: Maryland
|
|
|
Maybe you haven't initialized OLE?
|

April 14th, 2005, 12:34 PM
|
 |
Business Analyst
|
|
Join Date: Mar 2004
Location: The 'Ville
|
|
Try something like this perhaps? MSDN gives this example:
Code:
COleDateTime t2(COleDateTime::GetCurrentTime());
__________________
Discontent is the first necessity of progress. - Edison
|

April 14th, 2005, 04:27 PM
|
 |
Contributing User
|
|
Join Date: Jan 2004
Location: near St. Louis Illinois
|
|
It can't return -1 because it returns an COleDateTime object. I tried several different ways to generate the error and never got one. Even the program below was ok and MFC was not even initialized!
Code:
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
// if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
// {
// TODO: change error code to suit your needs
// cerr << _T("Fatal Error: MFC initialization failed") << endl;
// nRetCode = 1;
// }
COleDateTime t = COleDateTime::GetCurrentTime();
return nRetCode;
}
|

April 14th, 2005, 05:49 PM
|
 |
Renaissance Redneck
|
|
Join Date: Jan 2004
Location: Central New York. Texan via Arizona, out of his element!
|
|
Midnight, 29 December 1899 is – 1.0. Check your CMOS battery  .
__________________
Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it.
DaWei on Pointers Politically Incorrect.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|