問題:我在傳遞字符串時發現問題,並找出該字符串中的單詞。如何查找字符串中的特定字詞
我曾嘗試下面的代碼:
if(string.find("Z03"))
{
// field exists
return true;
}
字符串:Z030000000057
這裏就是我想要做的事:
if(string.find("Z03"))
{
// field exists
return true;
}
當我喜歡「的信息傳遞字符串; Z030000000057 「然後它進入循環,但當我只是通過」Z030000000057「它進入循環。
請幫助我。
閱讀[一些文檔](http://en.cppreference.com/w/cpp/string/basic_string/find)。 – juanchopanza 2014-09-22 11:59:54
查找不返回布爾值,它返回找到該字符串的位置的索引。你隱式地將int轉換爲bool。 [見文檔](http://en.cppreference.com/w/cpp/string/basic_string/find) – Borgleader 2014-09-22 12:00:00
是什麼循環? – 2014-09-22 12:04:43