int main() { char *str; str=returnStr(); printf("%s\n", str); return 0; }
/** @brief substr * */ CString CString::substr(size_type index, size_type numChars) const { // TODO should we do this so that the returned substr references the same // data to do that, we'd need a way to store an index into the data if(index > size()) { throw CStringOutOfBoundsException("CString::substr index > size"); } if(numChars == CString::NPOS) { numChars = size() - index; } if(index+numChars > size()) { throw CStringOutOfBoundsException("CString::substr index+numChars > size"); } CString returnStr(str()+index, numChars, DEFAULT_CAPACITY); return returnStr; }