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.

ccs中msp430g2553中sprintf的问题

Other Parts Discussed in Thread: MSP430G2553

程序主要部分如下:

#include <stdio.h>

#include <msp430g2553.h>

float input_voltage = 0;

char str_show[10];

sprintf(str_show,"%-04.3f",input_voltage);

input_voltage的值是正确变动的

sprintf运行后对str_show的值不产生效果

是ccs中不支持sprintf么

  • 我的ccs是5.1版本。win7 32位系统

  • 又做了个实验。貌似转换 sprintf(str, "%d", 123); //产生"123"

    整形的数据是可以的。但上面转换浮点型的不行

    求解答。。。

  • 您好!

    与您选择的printf run-time运行库有关系。如下设置库,选择full。然后再试试看。

    下面这一段是选自《MSP430 Optimizing C/C++ Compiler v 4.1 User's Guide》http://www.ti.com/lit/ug/slau132g/slau132g.pdf

    是关于printf库的支持情况。

    --printf_support={full| Enables support for smaller, limited versions of the printf and sprintf

    nofloat|minimal} run-time-support functions. The valid values are:

    • full: Supports all format specifiers. This is the default.

    • nofloat: Excludes support for printing and scanning floating-point

    values. Supports all format specifiers except %f, %F, %g, %G, %e,

    and %E.

    • minimal: Supports the printing and scanning of integer, char, or

    string values without width or precision flags. Specifically, only

    the %%, %d, %o, %c, %s, and %x format specifiers are supported

    There is no run-time error checking to detect if a format specifier is

    used for which support is not included. The --printf_support option

    precedes the --run_linker option, and must be used when performing

    the final link.

  • 鸵鸟蝈蝈,Thank you so much ,I love you !!

  • 我也遇到了输出小数的问题,按照你的方法修改之后问题得到了解决,但是整数好像不能输出了?你知道应该怎么做吗?