Intercept the specified string (pointer to)

Question: For example, the string const char *bb="abcdef;dsfads"; 
how to intercept the string before the ; number, abcdef forum link: http://topic.csdn.net/u/20100108/16/6eee2c27-2fad-4212 -a787-3ab68bf124d7.html?93233

nice answer
char *nn="abcdef"
 
 
const char*bb="abcdef;dsfads"int iLen =0; char* pIterator = bb; while(1) { if(*pIerator ==';') { break; } ++iLen; } char*pSubStr =newchar[iLen+1]; pSubStr[iLen] =0; memcpy(pSubStr,bb,iLen);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325605224&siteId=291194637