[英]How to convert double value to uint8_t string[] to print on terminal window in atmel studio
I am trying to convert some double values to uint8_t String[] (in C) when programming in Atmel Studio 6.2 in order to use it further in function: usart_write_buffer_job
. 我试图在Atmel Studio 6.2中编程时将一些双精度值转换为uint8_t String [](在C中),以便在功能中进一步使用它: usart_write_buffer_job
。
And this is the whole command I am going to use further, but instead of characters, I would like to print the given double values on the screen: 这是我将进一步使用的整个命令,但是我想在屏幕上打印给定的double值,而不是字符:
uint8_t string[] = "Hello World!\n";
usart_write_buffer_job(&usart_instance, string, sizeof(string));
I have tried casting, but it does not work properly in Atmel, as it does not recognize the (uint8_t*)(&MyDoubleValue)
我已经尝试过强制转换,但是由于它无法识别(uint8_t*)(&MyDoubleValue)
,因此在Atmel中无法正常运行
This looks like a job for snprintf
: 这看起来像是snprintf
的工作:
double d;
char string[50];
snprintf(string, 50, "%f", d);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.