|
You can see an example about it with socket search "Transfer file" on codeproject.
|
|
|
|
|
How do I pack two integer values in a double ?
i.e
<br />
int x=1000;<br />
int y=2000;<br />
<br />
double z;<br />
now I want the first four bytes to be occupied by x and the next 4 by y in Z
How do I do that? any shift operators would help? please tell me how do I pack & unpack it?
|
|
|
|
|
what about using union ?
union U {
double _d;
int _i[2];
};
|
|
|
|
|
Thank you for your reply sir, But I do not want an union The matter is,
You have a function like this. Imagine you cannot change it's params. It's built by someone and it's used in numerous instances.
<br />
void testDouble(double d)<br />
{<br />
cout<<d;<br />
}<br />
Now you say , testDouble(2143250); it prints 2143250. Now I want to send two integer values to this function for other reason. I have two numbres, 1000, 2000. these are ints so takes only 4 bytes.
<br />
double 00000000000000000000.....64<br />
now 0000000..32 | 0000.......32 is my idea.<br />
<br />
But how do I do that?
So that in the function, I can do like,
void testDouble(double d)
{
cout<<(HIGHER32)d;
cout<<(LOWER32)d;
}
get me now?
|
|
|
|
|
wait, you want to merge 2 ints into a double, or split a double into 2 ints ?
BTW be careful, sizeof(int) == 4 only on 32 bits plateforms !
|
|
|
|
|
|
int main(int argc, char* argv[])
{
__int32 i[2];
i[0] = 1000;
i[1] = 2000;
double d = 0;
d = *(double*)&i[0];
printf("%f\n", d);
__int32 *o;
o = (__int32*)&d;
printf("%d %d\n", o[0], o[1]);
return 0;
}
of course, anyone doing something like this would end up in the Daily WTF, for sure.
|
|
|
|
|
I'll test this & tell you. Thanks. BRB
|
|
|
|
|
Chris, that worked thanks. Now I'm happy I have a way. But if you can still get me a way that will never take part in WTFs that'd be excellent.
|
|
|
|
|
Is this what you are after:
int int
/-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-\
| | | | | | | | | | | | | | | | |
\-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-/
double
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
lol, David, are you moking at newbies ?
|
|
|
|
|
Moking? Do you mean mocking? No, I was just trying to clarify what the intent was by using a visual.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Moking? Do you mean mocking?
indeed i was.
but that's true also that pictures are more clear than words sometimes...
|
|
|
|
|
|
Hello members,
I have a VC++ 6 dialog based application as a stand alone exe which is called from a batch or a script file. How can I change the return code of my application to the operating system after closing my application? I want to check in the batch or script file, if the application worked fine or if an error has occured.
Hope anyone can help me.
Thanks
Juergen
|
|
|
|
|
your main() function must not be void if you want to return a value.
only then, you return the value you like, and knowing the meaning in the batch script, you can then catch it and test it...
|
|
|
|
|
Hello TOXCCT,
I do not a have a main(). I do have a WinMain() and this is somewhere in the installation directory of Visual C++ (I think in WinBase.h). This file is not (directly) part of my project.
|
|
|
|
|
oh sorry, dialog based project, i read console project...
anyway, if you use MFC, check the value returned by the InitInstance() method of your project.
|
|
|
|
|
Is there no function or message which can be used for setting the exit code of an application?
|
|
|
|
|
|
Return whatever value you want from CWinApp:ExitInstance() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi David,
thanks a lot. Exactly what I was looking for.
|
|
|
|
|
Hi guys,
writing a driver for a network interface, i'm faced with setting the QoS (Quality of Service) for each IP packet depending of the type of data being transmitted. now, we can transmit anything over the network: data, voice, video.. each of them must have its own QoS.
looking at data header from the data stream being passed to the driver could be a way but i'm wondering if it's really down that route, as there could be so many headers for different file formats.
any idea on how to determine the type of data being passed?
Thanks,
Fred
|
|
|
|
|
i am using the PlaySound function -Platform SDK: Windows Multimedia- to play .wav files, the problem is i need to know when this function finish playing the sound file and F.Y.I. when (fdwSound) parameter is set to SND_ASYNC "asynchronously", the function return immediately after beginning the sound.
also when (fdwSound) parameter is set to SND_SYNC "Synchronous", the function wait till it end the file playing and then return
i want to know :
1 - when the function finished playing the file if the (fdwSound)param. is SND_ASYNC
2 - OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC
thnx alot 4 ur time and concern !!
it is good to be here
|
|
|
|
|
Well, you could use PlaySound from a secondary thread, running synchronously then posting a thread message when it completes.
Steve S
Developer for hire
|
|
|
|