CPP 巨集的字串處理

2021-07-22 11:09:30 字數 697 閱讀 8610

1、#define a(line) ****_##line  

#define b(line) a(line)      

#define c int b(__line__) 

c; --> int ****_行號;

2、// 巨集定義涉及到字串連線##,字串化#, 則引數__line__不繼續展開

#define b(line) ****_##line

#define c int b(__line__)

c; --> int ****___line__;

3、#define a holy

#define b ****

#define c(a, b) a##_##b

#define d(a, b) c(a, b)

#define e d(a, b)

e;   -->holy_****

4、#include

#define m 1

#define n 2

#define a(a,b) a##b, a+b 

#define b(a)   #a, a

#define c(a) b(a)   

int main() 

c(a)的巨集定義無## 和 #, a(1,2)會被展開成12, 1+2;b(a)巨集定義有#,帶#的a a(1,2)不會繼續展開,不帶#的展開成12, 1+2;

Cpp高階 String 字串

正文結語 原來 c 中使用字串時,是乙個以 0結尾的字串行 char 而string庫提供了乙個字串類,提供一些基本的字串操作手段,將程式設計師從重複的方法構造中解放出來,也是大部分程式最常用到的類沒有之一。接下來就來看看到底該如何使用這個類吧。c c string 用法與心得完全攻略 修改字串 其...

字串處理 字串反轉

請原諒博主今天很閒,於是乎博主又開始更新微博了。這次要更新的問題是 編寫乙個函式,反轉乙個單詞的順序。例如 do or do not,there is no try.就要反轉成 try.no is there not,do or do 大家要認真看看這道題,這道題和大家想象的貌似有點不同。首先字串反...

字串的處理

st shig echo st 0 echo st 1 echo st 2 echo st 3 echo st.echo st.echo st.echo st.s echo strrev s fopen s,r or die 開啟失敗 echo n 547 sdhfue echo trim n,0....