This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

有关sprintf的问题

使用的处理器:F28335

使用的开发环境:CCSv4.2.3

优化等级:0

问题描述:我在CCSv4中使用simulator时如下语句可以将响应变量格式化到sci_buf中,但当在处理器中运行时就不可以,根据几次实验,主要是浮点变量引起的。不知道这是问什么,怎么解决?

谢谢。(各种库头文件已添加)

float32 freq,mag,phase;

char sci_buf[100];

freq = 2200;

mag = 768000.22;

phase = 23.23;

sprintf(sci_buf,"%%%% %-4d %c %-8.2f \n",22,'k',mag);

i = strlen(sci_buf);

SCI_Puts(sci_buf,i);