Click here to Skip to main content
15,906,567 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Declare string array in heap Pin
John R. Shaw25-Jun-07 20:27
John R. Shaw25-Jun-07 20:27 
AnswerRe: Declare string array in heap Pin
CPallini25-Jun-07 20:56
mveCPallini25-Jun-07 20:56 
Of course it depends on what you choose as a suitable string. For instance C-like strings are simply (NULL-terminated) character arrays, hence you can do something like:
char ** myStringArray;
myStringArray = new char * [3];
myStringArray[0] = "hello world";
myStringArray[1] = new char[10];
memset(myStringArray[1], '*',9);
myStringArray[1][9]='\0';
myStringArray[2] = strdup("Hi");
//Clean-up
delete [] myStringArray[1];
free (myStringArray[2]);
delete [] myStringArray;


On the other hand, MFC CString or std::string are objects controlling themselves the inner character buffer, therefore you can do, for instance:
CString * myStringArray;
myStringArray = new CString[2];
myStringArray[0]="Hello World";
myStringArray[0] += "!";// note CString dynamically controls its buffer
myStringArray[1]=CString('*',9);

// Clean-Up
delete [] myStringArray;


Hope that helps
Smile | :)

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.

QuestionWhat an I doing wrong with swprintf() Pin
frqftgbdafr25-Jun-07 17:23
frqftgbdafr25-Jun-07 17:23 
AnswerRe: What an I doing wrong with swprintf() Pin
Michael Dunn25-Jun-07 17:33
sitebuilderMichael Dunn25-Jun-07 17:33 
AnswerRe: What an I doing wrong with swprintf() Pin
Nibu babu thomas25-Jun-07 18:02
Nibu babu thomas25-Jun-07 18:02 
QuestionVirtual List View Pin
GameProfessor25-Jun-07 16:38
GameProfessor25-Jun-07 16:38 
AnswerRe: Virtual List View Pin
Mark Salsbery25-Jun-07 17:10
Mark Salsbery25-Jun-07 17:10 
GeneralRe: Virtual List View Pin
GameProfessor25-Jun-07 17:27
GameProfessor25-Jun-07 17:27 
GeneralRe: Virtual List View Pin
Mark Salsbery25-Jun-07 17:37
Mark Salsbery25-Jun-07 17:37 
GeneralRe: Virtual List View Pin
GameProfessor25-Jun-07 19:57
GameProfessor25-Jun-07 19:57 
QuestionHandling close button of Dialog based application Pin
rp_suman25-Jun-07 16:11
rp_suman25-Jun-07 16:11 
AnswerRe: Handling close button of Dialog based application Pin
Mark Salsbery25-Jun-07 16:28
Mark Salsbery25-Jun-07 16:28 
GeneralRe: Handling close button of Dialog based application Pin
rp_suman25-Jun-07 16:44
rp_suman25-Jun-07 16:44 
QuestionTemporary Internet Files Pin
locoone25-Jun-07 12:00
locoone25-Jun-07 12:00 
AnswerRe: Temporary Internet Files Pin
Hamid_RT25-Jun-07 22:43
Hamid_RT25-Jun-07 22:43 
QuestionSerialized MFC classes Pin
tom groezer25-Jun-07 10:22
tom groezer25-Jun-07 10:22 
AnswerRe: Serialized MFC classes Pin
Mark Salsbery25-Jun-07 13:58
Mark Salsbery25-Jun-07 13:58 
QuestionPS/2 Mouse Access Pin
Akin Ocal25-Jun-07 10:17
Akin Ocal25-Jun-07 10:17 
AnswerRe: PS/2 Mouse Access Pin
jk chan25-Jun-07 14:24
jk chan25-Jun-07 14:24 
AnswerRe: PS/2 Mouse Access Pin
Iain Clarke, Warrior Programmer26-Jun-07 1:44
Iain Clarke, Warrior Programmer26-Jun-07 1:44 
QuestionWindows Registry Pin
Akin Ocal25-Jun-07 10:17
Akin Ocal25-Jun-07 10:17 
AnswerRe: Windows Registry Pin
Perspx25-Jun-07 11:11
Perspx25-Jun-07 11:11 
QuestionButton down increment Pin
Oliver12325-Jun-07 9:48
Oliver12325-Jun-07 9:48 
AnswerRe: Button down increment Pin
jk chan25-Jun-07 14:27
jk chan25-Jun-07 14:27 
AnswerRe: Button down increment [modified] Pin
Mark Salsbery25-Jun-07 14:31
Mark Salsbery25-Jun-07 14:31 

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.