格式化字符串上的fprintf

时间:2015-01-19 09:46:56

标签: c

我试图让以下内容显示

static const char MSG[] = "Test %ld\n";
static int COUNT = 5;

fprintf(stdout, "%s", MSG, COUNT);

但此时,输出显示

Test %ld

如何格式化%ld以显示5?

1 个答案:

答案 0 :(得分:1)

试试这个:

#include <stdio.h>

int main ( void )
{
  static const char MSG[] = "Test %ld\n";
  static int COUNT = 5;

  fprintf(stdout, MSG, COUNT);

  return ( 0 );
}