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.

数据类型转换



请问28335如何可以把一个double型数据转换成char型字符串。我大概试了下下面的语句,然后不行。麻烦帮忙解答。

double y = 5689.56;
char V[10];
snprintf(V,sizeof(V),"%f",y);

  • 在C28x上,char 类型为16位宽。有时C代码假定char 是8位宽,所以可能会发生问题。考虑到这一点,请仔细检查此代码中的所有char 操作。

    请将所有char 变量更改为16位宽的变量,然后看看会发生什么。您可以尝试包括标准头文件<stdint.h>,并将char 替换为int16_t来使用。