c獲取任意字串的最後三位字元

時間 2021-07-01 02:05:53

1樓:

haha.substring(haha.length - 3, 3)

如果你要是想獲得副檔名名稱的話用fileinfo獲得了就行了

2樓:心心想嬉

int stringlength=haha.length;獲得字串的長度,也就是個數

string returnstr=haha.substring(stringlength-3,3);returnstr得到的字串

主要是運用字串提供函式substring(startindex,length)

3樓:匿名使用者

string haha="sfhgsjdflkjgkdf

string 後三位 = haha.substring(a.length-3,3);

3表示擷取的字元個數

4樓:匿名使用者

haha.substring(haha.length-4);

就行了因為長度和索引的差距是1,因此的-4;

(加分哦)

5樓:

string a = "asjflsjlfjsdf";

string 後三位 = a.substring( a.length - 3 ) ;

6樓:匿名使用者

用substring()

7樓:匿名使用者

string b = a.substring( a.length - 3 ) ;

c如何獲取字串除最後一位外的字元

仰起臉 微笑 如果是那你確定只不要最後一個字的話可以str.substring 0,str.length 1 如果不確定就用正則匹配數字 試試看這樣行不行 string str 3000張 string result system.text.regularexpressions.regex.matc...

C 中怎樣刪除字串中與另字串中相同的字元

include include include using namespace std int main cout str1 如何在c 的字串中刪除某個字串 千鋒教育 利用c的strstr函式查詢字串,然後strcpy拷貝覆蓋它。include int main 這裡只刪除了一處匹配的字串,如果有多...

c語言中怎樣將字串的第02468位置

大野瘦子 這樣 include include int main void int i char string 9 abcdefg for i 0 i 7 i i printf c string i return 0 會飛的小兔子 include include intmain charstr1 1...