# 和 ## 的区别
生活随笔
收集整理的這篇文章主要介紹了
# 和 ## 的区别
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
參考:# 和 ## 的區(qū)別
作者:枕上
發(fā)布時(shí)間:2021-07-25 08:23:40
網(wǎng)址:https://blog.csdn.net/jinchi_boke/article/details/119076280?utm_source=app&app_version=4.11.0&code=app_1562916241&uLinkId=usr1mkqgl919blen
#:
1、最常見(jiàn)的是 #不會(huì)替換參數(shù),只替換其所對(duì)應(yīng)的字符
2、 把宏參數(shù)變成一個(gè)字符串;
##:
把兩個(gè)宏參數(shù)連接到一起(只能兩個(gè))
Demo:
#include <stdio.h> #include <stdlib.h>#define ONE 1 //1.最常見(jiàn)的是 #不會(huì)替換參數(shù),只替換其所對(duì)應(yīng)的字符; #define toString(str) #str //2.轉(zhuǎn)字符串 #define hehe(x,y) x##y //連接int main() {printf("%d\n",ONE); //#不會(huì)替換參數(shù),只替換其所對(duì)應(yīng)的字符;printf(toString(123456)); //輸出字符串"123456"printf("\n %d \n",hehe(1,2)); //輸出 int 12char string[]="hello world!"; puts(hehe(str,ing)); printf("%s\n",hehe(str,ing));system("pause");return 0; }輸出結(jié)果:
1 12345612 hello world! hello world!總結(jié)
以上是生活随笔為你收集整理的# 和 ## 的区别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: wemosD1_WIFI模块 与 ard
- 下一篇: python拟合曲线求方程_matplo