|
|
Hi FISH786,
Change following
int mask = value >> bit;
with
int mask = 8 >> bit;
This code change is applicable for 4 digit binary number only.
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
Your mask calculations aren't quite right (in that you aren't necessarily generating a mask with a single bit set). Using a loop, I'd implement your conversion to binary like this:
char string[64] = {0};
int value = 2;
for (int bit = 3; bit >= 0; bit--)
{
const int mask = 1 << bit;
string[(3-bit)] = (mask==(value&mask))?'1':'0';
}
string[4] = '\0';
std::cout << string << std::endl;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
One interpretation looks like...
FISH786 wrote: char string[64];
Change this to:
char string[64] = { '\0' }; FISH786 wrote: int mask = value >> bit;
Remove this.
FISH786 wrote: if ((value & mask) == mask)
Change this to:
if (value & 1) Add this below the if /else :
value = value >> 1; FISH786 wrote: string[4] = '\0';
Remove this.
When the loop ends, your binary string will be in reverse order. A simple call to strrev() will fix that.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi,
I am loading JPG images using follwing code.
image.Load(Image);
HBITMAP hbmp = image.Detach();
if(hbmp == NULL)
{
Error = GetLastError();
}
Load function is failing and I am getting error code 33.
I am searching in google.But I am not getting any useful information.
can anyone help me.
|
|
|
|
|
From WinError.h :
//
// MessageId: ERROR_LOCK_VIOLATION
//
// MessageText:
//
// The process cannot access the file because another process has locked a portion of the file.
//
#define ERROR_LOCK_VIOLATION 33L
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In order to get the actual message from the OS you may use FormatMessage()
Something like:
DWORD dwError = ::GetLastError();
LPTSTR lpBuffer;
CString csErrorMsg;
if (::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), (LPTSTR)&lpBuffer, 0, NULL) != 0)
{
csErrorMsg.Format("%s", lpBuffer);
}
|
|
|
|
|
hemlat wrote: Load function is failing and I am getting error code 33.
If Load() is failing, you should be calling GetLastError() after it, not Detach() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi,
I have loaded a bitmap image to a dialog. The exe memory is increased by 1MB. The memory remains the same after closing the dialog. How to clear this memory.
Thanks,
|
|
|
|
|
May be the cleanup jobs are not done fully like bitmap's DeleteObject()
|
|
|
|
|
I have tried with DeleteObject function,but still memory is not getting reduced.
|
|
|
|
|
You should unload the bitmap. Refer the way youd load the bmp.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I am using LoadBitmap(nIDResource) to load image to dialog
|
|
|
|
|
will the CBitmap object get destroyed (or going out of scope)?
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Please show some code.
Regards,
Sandip.
|
|
|
|
|
Provided that you properly destroy the object, you don't have to worry about what Task Manager or similar tells you since it doesn't tell you what you think it does.
Read more here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
If you are dynamically allocating memory from the C++ heap, the heap will generally not be reduced in size when that memory is freed. One alternative would be to directly allocate your own memory from windows using GlobalAlloc.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi all,
I want to use pimstore.h and aygshell.h in application.
when i include these files in using class than number of errors comes as follows:
pimstore.h(2545) : error C2061: syntax error : identifier 'CEBLOB'
pimstore.h(5465) : error C3121: cannot change GUID for class 'Folder'
1>gt; c:\program files\microsoft sdks\windows\v6.0a\include\shldisp.h(1546) : see declaration of 'Folder'
aygshell.h(286) : error C2061: syntax error : identifier 'SIPSTATE'
1>gt;SMSpadDlg.cpp
please help me for this.
Thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: when i include these files...
Exactly where did you include them?
"_$h@nky_" wrote: pimstore.h(2545) : error C2061: syntax error : identifier 'CEBLOB'
This seems self-explanatory. No definition for CEBLOB was found prior to line 2545 of pimstore.h .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
I want to learn C++ to be able to program on game consoles (mostly PS2, PS3 and Wii, not 360 or XBox), do you need to learn different commands and libraries than under windows?
I mean, obviously MFC and the everything about displaying windows won't work, but what about the rest?
And is there a way to test and debug a game on a windows PC without having to burn it to disc and test it on the console every time?
Thanks.
|
|
|
|
|
Megidolaon wrote: I want to learn C++ to be able to program on game consoles (mostly PS2, PS3 and Wii, not 360 or XBox), do you need to learn different commands and libraries than under windows?
I suppose you've to use the proper development kit, for instance, PS3 possibly has it's own. But it's just a guess, since this morning I'm too lazy to google it for you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It is important to understand the language. I see 2 parts:
1. "pure" C++ language, as mathematical operations and working with memory and the powerful (and that why dangerous) pointer arithmetics.
2. working with libraries or frameworks to target devices.
The first is for at most all the same BUT the second differences for the platform. So the libraries are depending for what target you develop. There are also libraries with more or less portability available. Compare the QT with the MFC. Or the IE with the FF => and the Addons for it.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi
In my Server and Client (CSocket) Vc++ MFC application , I want to send Server system time to Client and Set the Local time in Client
SetLocalTime( SYSTEMTIME );.is for setting the local time.
How can pass the SYSTEMTIME object through the socket.
So I send from server and receive in Client and assign it.
Thanks and Regards
Shakumar
shakumar
|
|
|
|
|
I would pass it as any other chunk of data, i.e.
CSocket mySocket;
SYSTEMTIME st;
mySocket.Send(&st, sizeof(st));
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for u'r Reply
I tried u’r suggestion , sending is ok but how to receive it and type cast in to SYSTEMTIME
I Receiving as
char ch[1020];
CString m_str;
int m_Count = this->Receive(ch,strlen(ch));
ch[m_Count] = '\0';
m_str.Format("%s",ch);
AfxMessageBox(m_str);
Thanks & Regards
Shakumar
shakumar
|
|
|
|