20131229【C言語】#演算子を使う

お題

#演算子を使う

 

プログラム概要

MKSTRING関数を作成し、引数を#演算子を使って二重引用符付きの文字列に変換し、

変数の名前と値を表示させる

 

ソース


#include 

#define MKSTRING(str) # str

int main(void)
{
    int num;

	num = 10;

	printf("Value of %s is %d.\n", MKSTRING(num), num);

	return 0;
}

 

実行結果

 
Value of num is 10.