|
|
jeron1 suggested a very good article, indeed.
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]
|
|
|
|
|
I didn't I rated his post, however that is not my problem
(if you read my question) my issue is I need something such as BitConverter (in c#) in c/c++
|
|
|
|
|
Your question looks actually arising from a endianess problem; I doubt that a BitConverter -like class would be of any help.
Probably if you elaborate it a bit then we might properly appreciate your issue.
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]
|
|
|
|
|
CPallini wrote: Your question looks actually arising from a endianess problem; I doubt that a BitConverter-like class would be of any help.
Probably if you elaborate it a bit then we might properly appreciate your issue.
? like the question suggests I have converted it from big endian to little, but as stated I cannot just read straight into a double now, i must first grab the data into a char[], convert from big to small, then what I am left with is a char[] filled with binary data.. i need to convert from binary data into a double,int,or float... I could write my own function that would use the mantissa and all that for the float, but I don't think it should be that much trouble and there has to be an easier way of doing it
|
|
|
|
|
Greg Mort wrote: ...what I am left with is a char[] filled with binary data.. i need to convert from binary data into a double,int,or float...
Would a union work?
"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 have seen a few implementations of unions with similar threads, I however seem not to be able to get it to work, then again I have never used unions before
|
|
|
|
|
Never heard about union s?
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]
|
|
|
|
|
|
Greg Mort wrote: you cant read can you?
Yes, I'm able to (as a proof I can see a typo in your sentence... ).
Good luck with your reversed char[] and float .
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]
|
|
|
|
|
This is C++, you don't even need a union , you could just type-pun it directly, from a char[] to a double* or float* or whatever you want. The union isn't any better with Unidefined Behaviour here, only one member of the union is required to have a value at any one time - so it's just as bad as pointer-wise type-punning. Both methods should work anyway.
|
|
|
|
|
Thank you, I just figured this out as well
|
|
|
|
|
|
Looks like an endianess issue.
|
|
|
|
|
I agree, so how to I grab it from a file, reorder the data, and place the value in a double variable?
|
|
|
|
|
Maybe this[^] article will help.
|
|
|
|
|
Please look at the following lines of code.
<br />
PULONG count;<br />
PLUID* sessions;<br />
<br />
LsaEnumerateLogonSessions(count, sessions);<br />
I got the following error on that..
<br />
error C3861: 'LsaEnumerateLogonSessions': identifier not found, even with argument-dependent lookup<br />
Any idea why it's happen there in the code?
Thanks a lot
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Are you sure you're including the correct headers?
|
|
|
|
|
CodingLover wrote: Any idea why it's happen there in the code?
Are you including Ntsecapi.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
|
|
|
|
|
In my code I'm trying to call SendARP to get the MAC address of a computer on the local network. I have their IP address in the in_addr data format, but SendARP takes it as an IPAddr.
I looked on MSDN and they don't offer any explicit ways to convert between the two and google searches so far have not proven fruitful.
Anyone done this before?
|
|
|
|
|
I am BATMAN wrote: In my code I'm trying to call SendARP to get the MAC address of a computer on the local network. I have their IP address in the in_addr data format, but SendARP takes it as an IPAddr.
I looked on MSDN and they don't offer any explicit ways to convert between the two and google searches so far have not proven fruitful.
Anyone done this before?
Have you looked at the two definitions? IPAddr and in_addr ?
|
|
|
|
|
yes, that was sort of vague...are you talking about how it says you can cast an IPAddr to an in_addr? I tried casting the other direction (in_addr to IPAddr) but it throws errors.
Forgive me, this is basically the beginning of my windows C++ programming, up until now it's all been command line linux code. Is there a special way to cast with the win API or something?
|
|
|
|
|
I am BATMAN wrote: Forgive me, this is basically the beginning of my windows C++ programming, up until now it's all been command line linux code. Is there a special way to cast with the win API or something?
Then you need to study beginners material of the language since you need to understand types, structures and unions as well as many, many other things. Trying to explain them to you in a forum is not appropriate.
typedef struct in_addr {
union {
struct { UCHAR s_b1,s_b2,s_b3,s_b4; } S_un_b;
struct { USHORT s_w1,s_w2; } S_un_w;
ULONG S_addr;
} S_un;
The S_addr member of the union is the same type as IPAddr.
typedef ULONG IPAddr;
|
|
|
|
|
Oh ok, it worked when I saved the variable as a IPAddr the same way I was originally saving the in_addr instead of trying to cast between the two. Thanks anyways
|
|
|
|
|
Anybody has idea how to start specific service in remote using WMI C++ API.
Jack Rong
|
|
|
|