C++截取两个字符串中间的字符
例如获得We live in this world when we love it.中红色的部分in this world。
Win32 中 LPSTR 为 char*
LPSTR strcut(LPSTR old, LPSTR start, LPSTR end) { LPSTR strtmp1 = strstr(old, start); LPSTR strtmp2 = strstr(old, end); LPSTR newstr = new char[strtmp2-strtmp1+1]; memset(newstr,0,(strtmp2-strtmp1+1)*sizeof(char)); return strncpy(newstr,strtmp1,strtmp2-strtmp1-1); }