|
|
ok, so in the example above, it basically means
<br />
(if blah == 2)<br />
{<br />
foo = 1;<br />
}<br />
else<br />
{<br />
foo = 0;<br />
}<br />
<br />
pretty neat...thanks-o.
*.*
cin >> knowledge;
|
|
|
|
|
|
Hi,
do you mean the ? : operator????
This is just an abbreviation for an if else statement used in C++. Consider the following for example:
return x = a ? b< c : d > a;
In this case x is either (b<c) or="" (d="">a) depending on the programming return value.
Hope it helps.
Regards.
Alex
|
|
|
|
|
I was able to redistribute MSXML4 using a msi package. everything worked ok till i was working as administrator on a Windows 2000 box , when I logged on as a user I got an error in the XML part of the code saying that the object couldnt be created ! What do i need to do ?
|
|
|
|
|
Might be a permissions issue. Do you have the error code?
|
|
|
|
|
I am pretty confidant its bcos of permissions or things not getting setup globally ( like for all users , admins etc ) .
hr=m_plDomDocument.CreateInstance("Msxml2.DOMDocument.4.0");
if(FAILED(hr)){
::MessageBox(0,"Failed Dom Document CreateInstance",0,0);
I get the messageBox indicating an error while running as an User .
As an user I cannot even get access permissions to install the MSXML cab redistribution file to write certain registry keys !
|
|
|
|
|
You might want to check with the XML/XSL forum on this website.
|
|
|
|
|
I don't know much about thread programming, but I have a general question. Are threads more of an operating system function. For example there isn't any thread functions in the STL are there? Wouldn't threads be dealt with differently on Linux and Windows?
Thanks.
|
|
|
|
|
Anonymous wrote:
For example there isn't any thread functions in the STL are there?
Correct.
Anonymous wrote:
Wouldn't threads be dealt with differently on Linux and Windows?
While the implementation between the two OSs would no doubt be different, I suspect the net result of each would be somewhat similar.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
yes threads are part of the Operating system. Windows for example handles threads in a different manner than Unix or Linux does. Windows assigns to each thread a certain amount of time during which this thread can perform its task. If there are multiple threads at one time Windows determines which thread has priority of the others and executes this thread. Linux and Unix handle threads differently. The stl can also handle threads yet it does not have a special class or library that deals with threads. You have to write your own thread managing class or library.
|
|
|
|
|
Thanks for the information.
|
|
|
|
|
Hi all,
I was wondering if there was a way to parse a binary number that I receive over a TCP port, into either 4 bit chunks or into hex.
Thank you.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
DWORD dwSome32BitNumber;
WORD wFirstChunk = dwSome32BitNumber & 0x0000000f;
WORD wSecondChunk = (dwSome32BitNumber >> 8) & 0x0000000f;
WORD wThirdChunk = (dwSome32BitNumber >> 16) & 0x0000000f;
WORD wFourthChunk = (dwSome32BitNumber >> 32) & 0x0000000f;
... Does that make sense? Or you could dress it up a bit with:
WORD wChunks[8];
for (int nIndex = 0; nIndex< 8; nIndex++)
{
wChunks[nIndex] = dwSome32BitNumber & 0x0000000f;
dwSome32BitNumber >>= 8;
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi David,
Can you explain this to me a little more.
I think I understand , but I am not exactly sure what the dwSome32BitNumber >> 8 (16,32) or dwSome32BitNumber >>= 8 does exactly with respect to the &0x00000000f.
thanks again for your help
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
>> and << are right and left bit-shift operators, respectively. Read about them here:
http://tinyurl.com/o94p
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I'm sorry, I posted my message incomplete.
I updated the previous post. My question basically is if you are you the bitwise & operator with the first 8bits of the number, won't it end up being 0?
So i guess my real question is what does the & 0x00000000f do after the number has been shifted 8 (16, 32)?
thank you
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
NewHSKid wrote:
...what does the & 0x00000000f do...
Read about the bitwise-AND operator here:
http://tinyurl.com/o96t
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi David,
I know what the bitwise AND does, thats why i don't understand what you are saying. If I AND all 4 of the word chunks with 0x00000000f, then won't they all just evaluate to 0x00000000f because there is no 1's to match up to?
Please correct me, I have a feeling I am not thinking about this correctly.
Lets say I get the number as 0xA012B435. Using the bitwise AND will just make it 0. No?
Thanks for your help.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
AND means that BOTH bits must be 1 in order for the resulting bit to be 1.
10100000000100101011010000110101
AND 1111
================================
101
Continuing to bit-shift the value to the right one word at a time means that you can use 0x0000000f exclusively.
You could also have had something like:
DWORD dw = 0xA012B435;<br />
WORD w1 = dw & 0x0000000f;<br />
WORD w2 = (dw & 0x000000f0) >> 8;<br />
WORD w3 = (dw & 0x00000f00) >> 16;<br />
WORD w4 = (dw & 000000f000) >> 24;
or
WORD w4 = dw & 000000f000;<br />
w4 >>= 24;
Whether you bit-shift before or after the AND operation is not important, but doing so beforehand does lend itself to more readable code.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
yes you can split of the TCP address into its compounds and parse the compounds instead.
Regards.
Alex
|
|
|
|
|
I see that the groupbox is by default labeled IDC_STATIC and so is the label. Now if I change the IDs to IDC_GRPBOX and IDC_LBL, and do ctrl-W (class wizard in vc6), I do see IDC_LBL as a member of the class (its a dialog based project), but I dont see IDC_GRPBOX. I am trying to tie the groupbox to a variable name using the CW, so I can resize it along with the dialog (using MoveWindow in OnSize).
Why cant I give it a variable name? I guess I would have to use GetDlgItem but I have not found sample code to show how to use it...
Thanks,
ns
|
|
|
|
|
ns wrote:
I see that the groupbox is by default labeled IDC_STATIC and so is the label.
This makes no sense. There is only one control here. Look in the .RC file to verify. Changing the id from IDC_STATIC to IDC_GRPBOX is all that's required for ClassWizard to assign it a member/control variable.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks,
That did work. But really, if I put a label as well as group box, they both say IDC_STATIC:
DEFPUSHBUTTON "OK",IDOK,260,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,260,23,50,14
GROUPBOX "",IDC_GRPBOX,62,7,127,52
CONTROL "Local Source",IDC_RLOCAL,"Button",BS_AUTORADIOBUTTON,74,
15,106,20
CONTROL "FTP",IDC_RFTP,"Button",BS_AUTORADIOBUTTON,73,36,106,20
LTEXT "Static",IDC_STATIC,159,121,66,16
GROUPBOX "Static",IDC_STATIC,151,158,102,11
But I did see the grpbox in the CW after I renamed it.
Thanks,
ns
|
|
|
|
|
We recently upgraded to VC.NET 2003, and have noticed some alignment problems with some of our structures that we serialize to disk. I checked my old settings in VC6, and noticed that all the products have the "Struct Byte Alignment" set to 8 bytes. I wrote code that would check the sizes of all our serialized structs, and all the sizes were calculated correctly.
I then went over to VC7 and checked the project settings, he was also setup to 8 byte alignment. I ran the same size check code, and quite a few of the sizes are not the same as in VC6, which is causing us all kinds of headaches.
I've tried changing the alignments, and our structures are still off in VC7, even though the settings are the same. Has anyone else had this problem? Any tips/tricks? ... What kinds of things do you do when setting up a struct? Which items in the struct have to be on 4/8 byte boundaries etc?
Anything you can send would be appreciated.
Thx.
Mike.
doner@obtain.com
|
|
|
|