问题描述
看下面的代码
#include <stdio.h>#include <stdlib.h>#define call_optimized(function, arguments) { printf('n-------------'); printf('ntCALL %sn', #function); function arguments; printf('-------------n'); }void foo(char *str) { printf('%sn', str);}void foo2(char *str1, char *str2) { printf('%s, %sn', str1, str2);}int main(void) { printf('FIRST call_optimizedn'); call_optimized(foo, ('hell world')); printf('nSECOND call_optimized'); call_optimized(foo2, ('hell', 'world')); system('pause'); return 0;}
输出(手打):
FIRST call_optimized------------------CALL foohello world------------------CALL foo2hello, world------------------
宏中 printf('ntCALL %sn', #function); 输出函数名为什么要在前面加上 # 符号?求解释~
问题解答
回答1:这里的出现在define里面的#表示一个宏的连接传送见这里http://www.cnblogs.com/qinfengxiaoyue/ar...