我主要是從C++庫中尋找一個標準函數,它將幫助我在字符串內搜索一個字符,然後打印出從找到的字符開始的其餘字符串。我有以下情況:如何搜索和打印字符串中的特定部分?
#include <string>
using std::string;
int main()
{
string myFilePath = "SampleFolder/SampleFile";
// 1. Search inside the string for the '/' character.
// 2. Then print everything after that character till the end of the string.
// The Objective is: Print the file name. (i.e. SampleFile).
return 0;
}
在此先感謝您的幫助。請如果你能幫我完成代碼,我將不勝感激。
檢查'npos'是否合理。 –
@ MichaelKrelin-黑客好主意,修正,謝謝。 –
感謝您提供這樣準確的答案。 – CompilingCyborg