Click here to Skip to main content
15,920,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCstring to char * error Pin
kitty521-Jun-06 8:07
kitty521-Jun-06 8:07 
AnswerRe: Cstring to char * error Pin
Michael Dunn21-Jun-06 8:51
sitebuilderMichael Dunn21-Jun-06 8:51 
GeneralRe: Cstring to char * error Pin
kitty521-Jun-06 9:28
kitty521-Jun-06 9:28 
GeneralRe: Cstring to char * error Pin
Zac Howland21-Jun-06 9:35
Zac Howland21-Jun-06 9:35 
QuestionRe: Cstring to char * error Pin
David Crow21-Jun-06 9:38
David Crow21-Jun-06 9:38 
AnswerRe: Cstring to char * error Pin
Zac Howland21-Jun-06 13:20
Zac Howland21-Jun-06 13:20 
QuestionRe: Cstring to char * error Pin
David Crow22-Jun-06 2:33
David Crow22-Jun-06 2:33 
AnswerRe: Cstring to char * error Pin
Zac Howland22-Jun-06 3:20
Zac Howland22-Jun-06 3:20 
To get the desired result from it for this problem, you would have to make several subsequent calls to it while keeping track of where you are in the original string. Since the problem involves splitting a string by spaces, it is very simple to use the split method I gave to put each substring in the array as it is found and return the array.

The method is also reusable for future parsing of delimited strings (where using AfxExtractSubString would require either using it in another implementation of Split, or changing to code each time you want to use a different delimiter).

Finally, it is very easy to change the CString objects to std::string objects (and CStringArray to std::vector< std::string >) to make the Split method portable outside of just MFC (or even Windows altogether).

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac
GeneralRe: Cstring to char * error Pin
David Crow22-Jun-06 3:35
David Crow22-Jun-06 3:35 
GeneralRe: Cstring to char * error Pin
Zac Howland22-Jun-06 3:39
Zac Howland22-Jun-06 3:39 
GeneralRe: Cstring to char * error Pin
kitty521-Jun-06 9:52
kitty521-Jun-06 9:52 
GeneralRe: Cstring to char * error Pin
David Crow21-Jun-06 10:15
David Crow21-Jun-06 10:15 
QuestionRe: Cstring to char * error Pin
David Crow21-Jun-06 9:36
David Crow21-Jun-06 9:36 
AnswerRe: Cstring to char * error Pin
kitty521-Jun-06 9:50
kitty521-Jun-06 9:50 
GeneralRe: Cstring to char * error Pin
David Crow21-Jun-06 10:16
David Crow21-Jun-06 10:16 
GeneralRe: Cstring to char * error Pin
Zac Howland21-Jun-06 13:23
Zac Howland21-Jun-06 13:23 
QuestionRe: Cstring to char * error Pin
David Crow21-Jun-06 9:12
David Crow21-Jun-06 9:12 
AnswerRe: Cstring to char * error [modified] Pin
kitty521-Jun-06 9:29
kitty521-Jun-06 9:29 
QuestionRe: Cstring to char * error Pin
David Crow21-Jun-06 9:35
David Crow21-Jun-06 9:35 
Questionlist in mfc Pin
kamalesh8221-Jun-06 7:42
kamalesh8221-Jun-06 7:42 
AnswerRe: list in mfc Pin
led mike21-Jun-06 7:55
led mike21-Jun-06 7:55 
GeneralRe: list in mfc Pin
kamalesh8221-Jun-06 8:00
kamalesh8221-Jun-06 8:00 
GeneralRe: list in mfc [modified] Pin
Zac Howland21-Jun-06 8:35
Zac Howland21-Jun-06 8:35 
QuestionRe: list in mfc Pin
David Crow21-Jun-06 9:11
David Crow21-Jun-06 9:11 
AnswerRe: list in mfc Pin
led mike21-Jun-06 10:19
led mike21-Jun-06 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.