Click here to Skip to main content
16,004,924 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Delete [] charPtr... Pls help Pin
c121hains22-Jul-05 9:20
c121hains22-Jul-05 9:20 
GeneralRe: Delete [] charPtr... Pls help Pin
Michael Dunn22-Jul-05 9:47
sitebuilderMichael Dunn22-Jul-05 9:47 
GeneralRe: Delete [] charPtr... Pls help Pin
c121hains22-Jul-05 10:32
c121hains22-Jul-05 10:32 
GeneralRe: Delete [] charPtr... Pls help Pin
Jose Lamas Rios22-Jul-05 10:41
Jose Lamas Rios22-Jul-05 10:41 
GeneralRe: Delete [] charPtr... Pls help Pin
c121hains22-Jul-05 13:58
c121hains22-Jul-05 13:58 
GeneralRe: Delete [] charPtr... Pls help Pin
c121hains22-Jul-05 13:59
c121hains22-Jul-05 13:59 
GeneralRe: Delete [] charPtr... Pls help Pin
Michael Dunn29-Jul-05 19:26
sitebuilderMichael Dunn29-Jul-05 19:26 
GeneralRe: Delete [] charPtr... Pls help Pin
Jose Lamas Rios22-Jul-05 10:29
Jose Lamas Rios22-Jul-05 10:29 
c121hains wrote:
All i want to do is get all of the text together from an array of CString objects and put it into a single char* pointing to a string.

Try this:

void MergeLines(const CString* lines, int nLines, CString& result)
{
   // Get total length
   int nTotalLength = 1;  // at least a null terminator will be needed
   for (int i = 0; i < nLines; i++)
      nTotalLength += lines[i].GetLength();
 
   result.Empty();
 
   // Avoid re-allocating and copying in each iteration
   result.GetBuffer(nTotalLength);
   result.ReleaseBuffer();
 
   // Concatenate all strings into result
   for (int i = 0; i < nLines; i++)
      result += lines[i];
}


Disclaimer: I didn't compile it. May contain some error[s].

--
jlr
http://jlamas.blogspot.com/[^]
GeneralRe: Delete [] charPtr... Pls help Pin
c121hains22-Jul-05 13:57
c121hains22-Jul-05 13:57 
GeneralRe: Delete [] charPtr... Pls help Pin
Jose Lamas Rios22-Jul-05 14:29
Jose Lamas Rios22-Jul-05 14:29 
GeneralCheck if a thread is still running Pin
Budric B.22-Jul-05 5:42
Budric B.22-Jul-05 5:42 
GeneralRe: Check if a thread is still running Pin
David Crow22-Jul-05 5:44
David Crow22-Jul-05 5:44 
GeneralRe: Check if a thread is still running Pin
Budric B.22-Jul-05 5:50
Budric B.22-Jul-05 5:50 
GeneralAlso Pin
Budric B.22-Jul-05 5:52
Budric B.22-Jul-05 5:52 
GeneralRe: Check if a thread is still running Pin
David Crow22-Jul-05 5:56
David Crow22-Jul-05 5:56 
GeneralRe: Check if a thread is still running Pin
Budric B.22-Jul-05 6:01
Budric B.22-Jul-05 6:01 
GeneralRe: Check if a thread is still running Pin
Jim Crafton22-Jul-05 6:56
Jim Crafton22-Jul-05 6:56 
GeneralRe: Check if a thread is still running Pin
David Crow22-Jul-05 8:27
David Crow22-Jul-05 8:27 
GeneralRe: Check if a thread is still running Pin
Marc Soleda22-Jul-05 5:51
Marc Soleda22-Jul-05 5:51 
GeneralHelp, Overlapped I/O operation in progress Pin
inbakumar.G22-Jul-05 5:36
inbakumar.G22-Jul-05 5:36 
GeneralQuestion Pin
Alex_Y22-Jul-05 4:59
Alex_Y22-Jul-05 4:59 
GeneralRe: Question Pin
Marc Soleda22-Jul-05 5:43
Marc Soleda22-Jul-05 5:43 
GeneralRe: Question Pin
Alex_Y22-Jul-05 8:58
Alex_Y22-Jul-05 8:58 
GeneralRe: Question Pin
David Crow22-Jul-05 5:52
David Crow22-Jul-05 5:52 
GeneralRe: Question Pin
Alex_Y22-Jul-05 8:59
Alex_Y22-Jul-05 8:59 

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.