• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 605
  • Last Modified:

Converting Float to (char*) for Winsock sendv() + recv()

As I cannot type cast , Is there any way to do this ? Is there any function I can use to do this ? Is there any alternative network commands I can use to send floats ?

Thanks Mark
0
Paladin_VB
Asked:
Paladin_VB
  • 2
  • 2
1 Solution
 
mrwad99Commented:
Cant you just use sprintf ?

char buffer [50];

sprintf(buffer, "This is my float value %f", m_float);

(http://www.cplusplus.com/ref/cstdio/sprintf.html)
0
 
Jase-CoderCommented:
could you not use atof()
0
 
Jase-CoderCommented:
#include <stdlib.h>
 #include <stdio.h>

 int main(void)
 {
    float f;
    char *str = "5432.123";

    f = atof(str);
    printf("string = %s float = %f\n", str, f);
    return 0;
 }
0
 
Paladin_VBAuthor Commented:
Thanks to to all who replied
0
 
mrwad99Commented:
Glad to help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now