string——substr(int index1,int index2),取string子串。c_str,const,不可修改,這將非常不方便。
String——的適配器。聲明:string::iterator it;it =s.begin(); it = s.end();但輸出只能用 cout << *it,輸出當前it所指的字符,若需要輸出整個string,則用for(it=s.begin(), it != s.end(); it++) cout << * it。若用cout << it 則會報錯。
String 與 char*的轉換。不能有 c =(char*) s,只能用strcpy(c, s.c_str() );但可以寫s = (string)c(顯示轉換),或s = c(隱式轉換)。可以用map <string, int> h; 來測試。
Sscanf 與 char*的結合。可以用char *p = s; sscanf(p, “%s”, to)。
map——可以直接賦值,也就是說,可以很方便的作爲函數返回值返回,也可以通過引用修改實參的map。
Sscanf ——函數返回值,爲讀入的有效數據的個數。例如,“%d”,這麼樣則爲1.類似於scanf。若爲“%d%d”,則爲2.