这行代码会做什么。
pcm->card->number
,pcm->device
都是int
。
char str[16];
sprintf(str, "pcmC%iD%ip", pcm->card->number, pcm->device);
它取自 android/kernel/sound/core/pcm.c。
最佳答案
截至the description of sprintf()
和 fprintf()
, %i
是
The int argument is converted to a signed decimal in the style [-]dddd. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it will be expanded with leading zeros. The default precision is 1. The result of converting 0 with an explicit precision of 0 is no characters.
所以结果是例如pcmC12D23p
如果 pcm->card->number == 12
和 pcm->device == 23
。
关于c - sprintf中的pcmC%iD%ip参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11290355/