Don't forget that if you READ a string from RS232, there is no terminating
null.
"Shiner" wrote in message
news:506500000005000000C4890000-1023576873000@exchange.ni.com...
> To convert from a double/float to say a string I tend to use the
> following:
>
> #define OUTPUT_STRING "pwr=%f dBm\n"
>
> sprintf (pszMyOutputString,OUTPUT_STRING,"45.56");
>
> The string "pszMyOutputString" should now contain "pwr = 45.56 dBm\n"
> which you can send to your rs232
>
>
>
>
> --
> To convert from string to say float (or double in this case) you can
> use the strtod function.
>
> *pdValue = strtod (pszTmp, NULL);
>
> pdValue is a pointer to a double to contain the result.
>
> pszTmp is a point to a null terminated string that contains the
> floating point number
.
>
> the NULL is this case is used to indentify the first character in
> pszTmp that I do not want to convert
> (so if I had 3.14dBM), I would point the 'd' and not a NULL).
>
> aDouble= strtod ("3.14", NULL);
>
>
> Hope this helps, if not, let me know and I can elaborate further,
>
> Regards
>
> Chris