c - sprintf中的pcmC%iD%ip参数

标签 c linux linux-kernel printf

这行代码会做什么。

pcm->card->numberpcm->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 == 12pcm->device == 23

关于c - sprintf中的pcmC%iD%ip参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11290355/

相关文章:

linux - 在(CentOS 6.5)2.6.32内核中编译2.4.20内核

linux-kernel - 进程堆栈和 CPU 堆栈之间有什么区别?

无法在 netbeans 中运行我的 C 代码

c - 枚举类型和从特定枚举类型创建的变量的用途是什么

c++ - raise(SIGABRT) 和 abort() 方法之间的区别

linux - dh : unable to load addon autoreconf in Ubuntu 14. 04

python - Cloudflare API 将代理参数默认为 false

c - read, fread 部分读取

linux - 帮助理解 GDB 中一个非常基本的 main() 反汇编

android - 内核 c 多重函数定义错误