1

在我的 C 程序中,我正在使用命令终端打印一个字符串,printf("%d %s %s\n", node->id, node->date, node->input);但我现在需要使用 write 函数write(STDOUT_FILENO, cmdline, strlen(cmdline));......

如何像使用 printf 一样格式化字符串?

4

1 回答 1

10

使用sprintf/snprintf将字符串格式化为字符缓冲区,然后write使用它。

于 2013-01-13T00:32:32.443 回答