|
-
February 24th, 2002, 01:17 AM
#1
Convert double to string / Send double using UDP
Hi! Is there a library function that lets me easily convert a double into a char* string?
Or, if what I really want to do is to send a double using UDP using its sendto() funciton, how can I send and receive the double?
Thanks a lot!
-
February 24th, 2002, 01:42 AM
#2
Re: Convert double to string / Send double using UDP
>> Hi! Is there a library function that lets me easily convert a double into a char* string?
double dftValue = 3.1774;
char szString[25] = "";
sprintf(szString, "%.6lf", dftValue);
>> Or, if what I really want to do is to send a double using UDP using its sendto() funciton, how can >> I send and receive the double?
double dftValue = 3.1453;
sendto(Socket, reinterpret_cast<const char *>(dftValue), sizeof(dftValue), 0, NULL, 0);
Ciao, Andreas
"Software is like sex, it's better when it's free." - Linus Torvalds
-
February 24th, 2002, 01:43 AM
#3
Re: Convert double to string / Send double using UDP
It should be
sendto(Socket, reinterpret_cast<const char *>(&dftValue), sizeof(dftValue), 0, NULL, 0);
in my previous post....
Ciao, Andreas
"Software is like sex, it's better when it's free." - Linus Torvalds
-
February 24th, 2002, 02:42 AM
#4
What about longlong to string?
How about converting LONGLONG to string, and coverting string to LONGLONG??
Thanks!
-
February 24th, 2002, 10:42 AM
#5
Re: What about longlong to string?
1. LONGLONG to string
#include <stdlib.h>
char szBuffer[50] = "";
LONGLONG llLongLong = 5365462;
_i64toa(llLongLong, szBuffer, 10);
2. String to LONGLONG
#include <stdlib.h>
char szBuffer[] = "376329987";
LONGLONG llLongLong = _atoi64(szBuffer);
Ciao, Andreas
"Software is like sex, it's better when it's free." - Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|