把一个array拷贝到vector
其中的copy方法里,copy(&dataArray[0], &dataArray[dataArraySize], back_inserter(dataVec));
不会拷贝dataArray[dataArraySize]
元素;例子如下:
1 | int arr[] = {1,4,2,4,56,5,43,2,2,5}; |
1 | vector<int> dataVec; |
按符号切割字符串
1 | std::string s = "scott>=tiger"; |
- The
find(const string& str, size_t pos = 0)
function returns the position of the first occurrence ofstr
in the string, ornpos
if the string is not found. - The
substr(size_t pos = 0, size_t n = npos)
function returns a substring of the object, starting at positionpos
and of lengthnpos
.
删除字符串中的空白符号
1 | s.erase(remove_if(s.begin(), s.end(),::isspace), s.end()); |