共找到3條詞條名為substr的結果 展開

substr

C++語言函數

substr是C++語言函數,主要功能是複製子字元串,要求從指定位置開始,並具有指定的長度。如果沒有指定長度_Count或_Count+_Off超出了源字元串的長度,則子字元串將延續到源字元串的結尾。

定義和用法


basic_string::substr
basic_string substr(size_type _Off = 0,size_type _Count = npos) const;
參數
_Off
所需的子字元串的起始位置。字元串中第一個字元的索引為 0,默認值為0.
_Count
複製的字元數目
返回值
一個子字元串,從其指定的位置開始

示例


Code : C++中 的代碼如下
輸出結果:
The original string str1 is:
Heterological paradoxes are persistent.
The substring str1 copied is: logical
The default substring str3 is:
Heterological paradoxes are persistent.
which is the entire original string.
}
在oracle中的用法:
SUBSTR(:NEW.FLAGSTATUS,17,1)
其中參數依次是(開始,長度),並返回子串。