How to separate a string to several parts?
-
Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk
-
Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk
-
Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk
you've got a function which synopsis is the following
CString CString::Mid(int nFirst, int nCount) const;
nFirst
is the position of the first char you want to extract (pos 0 for the first of the string),nCount
is the number of chars you want. look at the MSDNCString Class Members
for more details
TOXCCT >>> GEII power
-
Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk
See if
AfxExtractSubString()
is of any help.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk
Use CString.Tokenize into split separate strings, and use CString.AppendFormat("\"%s\"", ...) and CString.Apend(",") to build the new string.
-
Hello everyone: How to separate a string to several parts fastly in a MFC project? Example: string A is "abc efg @ # !!23 456 =" Is there a fast good way to separate A to "abc","efg","@","#","!!23","456","=" ? Do you have or know any samples or ways? Please help me. Thank you. -Freehawk
UpdateData(TRUE); CString erg[20]; int a,b,z; z=0; a=0; for(;;) { b=m_text.Find(" ",a); if(b<0) { erg[z]=m_text.Mid(a,m_text.GetLength()-a); break; } erg[z]=m_text.Mid(a,b-a); a=b; a++; z++; }