How to split the CString variable in MFC?(Very Urgent..............)
-
Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)
-
Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)
CString::Tokenize() ? For urgent purposes, you can try TokenizeUrgnz().
It is a crappy thing, but it's life -^ Carlo Pallini
-
Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)
You can use
AfxExtractSubString()
."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
CString::Tokenize() ? For urgent purposes, you can try TokenizeUrgnz().
It is a crappy thing, but it's life -^ Carlo Pallini
Welcome in the CP's Memorable Quotes [^], man! :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Welcome in the CP's Memorable Quotes [^], man! :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Thank you. Now, *that* is a honor. :-O It took me a while to make it to the list though. :rolleyes:
It is a crappy thing, but it's life -^ Carlo Pallini
-
Hi All, How to split the CString in MFC? My clode is: CString str; str = "READ rd659885676R8667U7788"; I need to split the CString with " "(space). That is i need "READ" in one variable and "rd659885676R8667U7788" in another variable. Please help me......... Regards, Anitha :)
Hi Anitha, You can use this code: void CSplit::Split(CString str, CString separator, CStringArray& array) { CString aux; int pos; pos = 0; array.RemoveAll(); for (int i=0; i<str.getlength();> { if (str[i]==separator) { aux = str.Mid(pos,(i-pos)); pos = i+1; array.Add(aux); } } aux = str.Mid(pos,str.GetLength()-pos); array.Add(aux); } Regards, Gustavo