What does it take to get formatted I/O to work in MQX?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

What does it take to get formatted I/O to work in MQX?

ソリューションへジャンプ
545件の閲覧回数
wavesoftware
Contributor I

float answer;

char buffer[] = "12.34";

sscanf(buffer, "%f", answer);

// answer is always 0.0, no matter what I put in buffer.

// what's the trick?

1 解決策
391件の閲覧回数
KJFPE
Contributor III

Hi

You need an ampersand, I am surprised the program just dosnt crash

ie

float answer;

char buffer[] = "12.34";

sscanf(buffer, "%f", &answer);

元の投稿で解決策を見る

2 返答(返信)
392件の閲覧回数
KJFPE
Contributor III

Hi

You need an ampersand, I am surprised the program just dosnt crash

ie

float answer;

char buffer[] = "12.34";

sscanf(buffer, "%f", &answer);

391件の閲覧回数
BielikM
Contributor III

Hi,

Probably default setting of FPU for your board is disabled. Check MQX_INCLUDE_FLOATING_POINT_IO macro at <MQX directory>\config\<Name of your board>\user_config.h. This macro is responsible for floating operations inside FIO component(STDIO alternative).

Set this macro to 1, rebuild libs and your app...should works.

Regards,

Martin Bielik

0 件の賞賛