|
How can i get the system time and display it?
|
|
|
|
|
shamsteady wrote: How can i get the system time...
Use GetSystemTime(), or time() .
shamsteady wrote: ...and display it?
Use printf() , or cout .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
It said GetSystemTime() is undeclared. Am i missing something?
|
|
|
|
|
shamsteady wrote: Am i missing something?
Yes, the inclusion of a header file.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
shamsteady wrote: Yes, the inclusion of a header file.
shamsteady wrote: t said GetSystaremTime() is undeclared. Am i missing something?
which compiler are you using@!
|
|
|
|
|
Also, you can use the time_t structure.
time_t t;
time(&t);
cout<<ctime(&t);
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
See
SYSTEMTIME m_SysTime;
char DisplayTime[255];
::GetSystemTime(&m_SysTime);
sprintf(DisplayTime,"%d/%d/%d...%d::%d::%d::%d",
m_SysTime.wMonth,m_SysTime.wDay,
m_SysTime.wYear,m_SysTime.wHour,
m_SysTime.wMinute,m_SysTime.wSecond,m_SysTime.wMilliseconds);
|
|
|
|
|
Hi All,
I'm trying to overload the assignment (=) operator so that I can achieve the following:
int x = myclass;
instead of:
int x = myclass.Value();
I am implementing it as follows:
class CMyClass
{
private:
int m_nValue;
public:
int& operator=(CMyClass& class);
int Value() { return m_nValue; };
};
int& CMyClass::operator=(CMyClass& class)
{
return class.Value();
}
But I keep on getting a compiler errors either saying that there is no suitable conversion, or that it cannot convert from CMyClass to int.
Clearly my syntax (or something) is screwed, so how can I fix it ?
Thanks
OD
|
|
|
|
|
Write a casting operator instead:
operator int() const { return m_nValue; }
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Damn, you were faster
|
|
|
|
|
Nemanja Trifunovic wrote: Damn, you were faster
Hehe, sometimes I get lucky.
Haven't refreshed in about two hours.
It was a good thing that we suggested the same thing though...
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks, worked like a charm !
|
|
|
|
|
od@ananzi.co.za wrote: I'm trying to overload the assignment (=) operator so that I can achieve the following:
int x = myclass;
instead of:
int x = myclass.Value();
If I got your intention correctly, you need operator int , not operator =
|
|
|
|
|
I'm porting a legacy app. This code was fine in VC6, but VS2005 doesn't
like it:
struct CColumnBool
{
std::vector<bool> m_vBoolData;
CColumnBool()
{
m_vBoolData.clear();
};
bool& operator[](UINT uiRow)
{
return m_vBoolData[uiRow]; // <--- error on this line...
};
const bool& operator[](UINT uiRow) const
{
return m_vBoolData[uiRow];
};
};
The error is this:
error C2440: 'return' : cannot convert from 'std::_Vb_reference<_MycontTy>' to 'bool &'
with
[
_MycontTy=std::vector>
]
The weird thing is that this code does NOT generate the same error:
struct CColumnInt
{
std::vector<int> m_vIntData;
CColumnInt()
{
m_vIntData.clear();
};
int& operator[](UINT uiRow)
{
return m_vIntData[uiRow];
};
const int& operator[](UINT uiRow) const
{
return m_vIntData[uiRow];
};
};
C2440 is a type conversion error, of course. MSDN lists several
causes for this, but I don't see where they apply. Any ideas
how to fix this?
|
|
|
|
|
|
Adis H. wrote: This may help perhaps:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1354391&SiteID=1[^]
Yes, that's it exactly. Thanks!
|
|
|
|
|
std::vector<bool> is not based on an array of bool . Instead the bits are packed, and as such it is impossible to take the address of any given bit, or create a reference to it. Instead operator[] has to return a proxy class.
This is a specialization of the vector template required by the C++ standard. This is widely considered to be a massive error in the standard. Unfortunately it is required, in order to claim conformance to the standard.
|
|
|
|
|
Mike Dimmick wrote: This is widely considered to be a massive error in the standard.
I would think so. Thanks for the explanation.
|
|
|
|
|
Hi
Is it possible to open a html-file at a given anchor-point using ShellExecute? Or should I use another method?
I tried to use the following argument to ShellExecute open
file://C:/afile.htm#alocation
and the file opens, but always from the top.
drives me crazy
tia
|
|
|
|
|
::ShellExecute(NULL, _T("open"), _T("C:\\afile.htm#alocation"), NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
|
Honestly, you haven't tried that, have you?
Do you at all think it will work?
|
|
|
|
|
Niklas Lindquist wrote: Honestly, you haven't tried that, have you?
yes i did, and you ?
Niklas Lindquist wrote: Do you at all think it will work?
not it will, it does !
|
|
|
|
|
I get ERROR_FILE_NOT_FOUND from that. (Which to me seems like a reasonable thing, since the number character is valid in a windows path.)
Adding "file://" in front will bring up the correct file, but always shown from the top.
Removing "#alocation" also works (in that it brings up the correct file, but not located at the anchor point obviously).
WinXP IE6
I still doubt that it works for you.
|
|
|
|
|
ah, sorry, it was the anchor that matters... have you tried passing te anchor parameter into the "parameters" argument ?
like this (this one, i didn't test) :
::ShellExecute(NULL, _T("open"), _T("C:\\afile.htm"), _T("#alocation"), NULL, SW_SHOWNORMAL);
|
|
|
|
|
Been there, done that.
Right now it feels like I've tried every single possibility but the right one.
Maybe one should use another function altogether? Or is it even impossible, since I'd like it to work with Firefox et al aswell, depending on default browser? I don't want to add browser dependencies to the code.
|
|
|
|