LoginSignup
0
1

More than 1 year has passed since last update.

C言語で文字列リテラル又はマクロを連結する方法

Posted at

以下のように連続して書ける マクロが連続する場合はスペースを1つ空ける

#include <stdio.h>
#define PRIuPTR "lu"

int main()
{
  char *a1 = "abc""" PRIuPTR PRIuPTR ""   "def";
  printf("%s\n", a1);
  return 0;
}
$ clang main.c
$ ./a.out
abcluludef
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1