View Single Post
  #2 (permalink)  
Old September 26th, 2006, 11:46 AM
hollymatrix hollymatrix is offline
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi.

the problem with you code is that you are returning a local variable outside the function (out side the scope)

when a function is called, all it's local variables are created in the stack, so your buffer[2000] is in the stack, and when the function returns the local variables does not exist any more.

you can do this :

//================================================== ==========//
void PutDataInMemory(const CString &rkcstrData, char* buffer){
   int nDataSize = rkcstrData.GetLength();

   for(int nCounter=0; nCounter<nDataSize; nCounter++){
      buffer[nCounter] = rkcstrData.GetAt(nCounter);
   }
}


Reply With Quote