|
Something like the following, with maybe a tweak or three:
struct tm time_in = { 0, 0, 0, 1, 7, 2013 - 1900 };
time_t time_out = mktime(&time_in);
struct tm *time_local = localtime(&time_out);
_tprintf(_T("%u\n"), time_local->tm_wday);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
|
Nice idea, but the OP was looking for something portable.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I would suggest converting the date to a Julian Day Number. Here is a function we use to convert day, month and year to such a number. The input values (D, M, Y) are all unsigned int.
unsigned int yh = Y;
unsigned long c, ya, j;
if (M > 2)
{
M -= 3; }else{
M += 9;
Y--;
}
c = Y / 100;
ya = Y - 100*c;
j = ((146097*c)>>2) + ((1461*ya)>>2) + (153*M + 2)/5 + D;
Using that you just need the Julian Day Number corresponding to a date for which you know the day of week as a reference. You can then subtract the numbers to get the days in between.
Please note that the function is only valid from 14th September 1752 (when the Gregorian calendar started).
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Question 1. Read two unsorted list of numbers. Sort the lists individually and finally merge the two lists to form a single sorted list. Define and use function readlist(l) to read list l and sort(l) to sort the list l.
Question 2. To read two square matrices and check whether multiplication of these matrices is commutative or not.
|
|
|
|
|
Answer (1,2) : Write some code !
|
|
|
|
|
You are knocking on the wrong door. This is not a site that writes the homework of students. These questions are far from being serious enough to waste the free time of a programmer. You should have enough free time for this as currently your full-time work is learning programming by completing these simple and boring tasks. Also please read my advice: here[^].
|
|
|
|
|
|
|
How can I get address of current page in Firefox?
|
|
|
|
|
Its address in memory? Is this a C/C++/MFC question?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
thanks for your answer. It is obvious that it resides in memory
but how can I find its address. furthermore I think that it is
related to C/C++. take it easy.
|
|
|
|
|
|
thanks for your favor. If writing an add-on is intended, it is true
but I don't want to write an add-on. I just want to manipulate it
from outside.
|
|
|
|
|
You could try to get the process handle of Firefox and from that, get the handle of the windows (HWND) and enumerate the child windows to find the one containing the address bar and do a GetWindowText on that child window.
A quick look with Spy++ does not help finding the address bar window (or edit box) so it might be more involved than that
good luck.
I'd rather be phishing!
|
|
|
|
|
It doesn't work. Elements in Firefox aren't standard windows element. They are handled by firefox. try SPY++ to see what I
am talking about.
|
|
|
|
|
Hi all. Suppose a BaseClass has two childs. Now when the childrens' constructors are called, the base class' constructor is also called. Here is the scenario, in code.
class BaseClass
{};
class ChildOne : public BaseClass
{
public ChildOne(){}
};
Class ChildTwo : public BaseClass
{
public ChildTwo(){}
};
Do the childs share the same parent instance? I wanted to know a little more deep information about BaseClass instance and the two child instances. Thanks
This world is going to explode due to international politics, SOON.
|
|
|
|
|
No, if you create two separate instances of the child class, then you also get two separate instances of the base class.
But, of course, any static members are shared between all instances of the base and/or the child class.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
If you mean that base class have same values whenever an object of its child classes are made then yes same class have 'same instance'. But, it is false in the sense that each time an object is created, its new instance is created in memory. So, when you are creating the instance of a child class, its respective base class' instance is also created in memory. And if you are creating two instances of two child classes derived from same base class, then two different instances of base class are also getting created in memory against both child objects.
|
|
|
|
|
An instance of a class is created when memory is allocated for the class.
In the code that you've shown, there is no instance created and no memory allocated.
Refer to the code snippet below -
class BaseClass
{
int base;
};
class ChildOne : public BaseClass
{
int childOne;
public ChildOne(){}
};
Class ChildTwo : public BaseClass
{
int childTwo;
public ChildTwo(){}
};
When an object of ChildOne is created, memory is allocated for int base; and int childOne;
When an object of ChildTwo is created, memory is allocated for int base; and int childTwo;
Here you can see that memory for int base; has been allocated twice, once for the instance of ChildOne and once for the instance of ChildTwo .
So base has separate memory and hence value for each instance.
|
|
|
|
|
Hi,
I am using CreateDIBSection() function frequently in my code but sometimes it is failing.
The value of biWidth is around 6000, biHeight is 4000 and biBitCount is 24 in BITMAPINFOHEADER.
My doubt is on memory, can someone please tell how much meomory is consumed by each call of CreateDIBSection() considering the values which is mentioned earlier.
|
|
|
|
|
How do you know it's failing? Do you get an exeception, error return, message ... ? Please provide proper details of exactly what code fails and what response you see.
Veni, vidi, abiit domum
|
|
|
|
|
I am getting a NULL value in return and ppvBits is also NULL.
Actually sometimes one failure is there at some other place in code while allocating meomory where the i am getting windows error code 8.
So i thought that it could be related to memory which is getting consumed by each call to CreateDIBSection() function though i am calling DeleteObject() after using the bitmap.
Thanks
|
|
|
|
|
Well you need to check the error code every time you get an error response and try to figure out why it is being given. Error code 8 says Not enough storage is available to process this command., so that is reasonably clear.
Veni, vidi, abiit domum
|
|
|
|
|
The error code 8 I am getting at some other place in code while calling the function ::MapViewOfFile() and not while calling CreateDIBSection().
Following is the code snipet
void create(const CSize& size)
{
initBitmapInfo(size);
mBitmap = ::CreateDIBSection(0,
getBitmapInfo(),
DIB_RGB_COLORS,
(LPVOID*) &mBits,
0,
sizeof(BITMAPINFOHEADER));
if (mBitmap == 0 || mBits == 0)
{
cout << "NcSurface::destroy()-------- mBitmap = " << mBitmap<< endl;
cout << "NcSurface::destroy()-------- mBits = " << mBits << endl;
cout << "NcSurface::destroy()-------- size.cx = " << size.cx << endl;
cout << "NcSurface::destroy()-------- size.cy = " << size.cy << endl;
ErrorInstance::instance()->throwError(__FILE__, __LINE__, GdiException());
}
}
void initBitmapInfo(const CSize& size)
{
BITMAPINFO* bmi = getBitmapInfo();
CHECK(bmi != 0);
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi->bmiHeader.biWidth = size.cx;
bmi->bmiHeader.biHeight = size.cy;
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biBitCount = 24;
bmi->bmiHeader.biCompression = BI_RGB;
bmi->bmiHeader.biSizeImage = 0;
bmi->bmiHeader.biXPelsPerMeter = 0;
bmi->bmiHeader.biYPelsPerMeter = 0;
bmi->bmiHeader.biClrUsed = 0;
bmi->bmiHeader.biClrImportant = 0;
}
size.cx = 6000 and size.cy = 4000
|
|
|
|