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.
以下是我的printf函数:
该函数打印不了32位的数据但是可以打印16位的数据,应该如何实现32位数据的打印呢?
两个16位的数据不能合成一个32位的数据?这是什么原因?
您需要更改 CCS 中的 sprintf 设置以支持 32 位值。启动新项目时,它默认设置为“minimal”。另外两个选项是“nofloat”和“full”。当您不打算使用浮点数时,“nofloat”就足够了。但是“minimal”不能处理 32 位。为此 -在项目资源管理器中右键单击您的项目名称,然后选择“Properties”。然后转到此选项并选择右侧的“nofloat”:
现在 sprintf 将支持32 位,但此外您必须告诉它正在使用一个长变量,因此在函数调用中添加一个额外的“l”。类似下面的这样
sprintf( print_str, " FileIndex %x\n", FileIndex );
将更改为
sprintf( print_str, " FileIndex %lx\n", FileIndex );
如果您希望十六进制全部为大写,则将“x”设为大写
sprintf( print_str, " FileIndex %lX\n", FileIndex );
当然,请确保您的print缓冲区有足够的字节来保存结果。