0

我正在尝试为 lcd 创建动态 printf 大小,但它只输出 f= 我做错了什么?

sprintf(buffer, "f=%.2f",  (d = d + 0.01)); <-- works but not dynamic 

sprintf(buffer, "f=%.*f", 2 , (d = d + 0.01));  <-- Does not any give warning

lcd_puts(buffer);


_delay_ms(100);
4

1 回答 1

1

可能你需要这个:

字符格式[10];
int len1 = 5, len2 = 2;
sprintf(格式, "f=%%%d.%df", len1, len2);
sprintf(缓冲区,格式,(d = d + 0.01));
于 2012-07-11T11:35:26.217 回答