Array of datas returning issue, Overwriting

Posted by sijith on Stack Overflow See other posts from Stack Overflow or by sijith
Published on 2010-04-19T11:41:57Z Indexed on 2010/04/19 11:43 UTC
Read the original article Hit count: 182

Filed under:
|
|
|

Hi, Please help me on this Here i want to save the converted data into new pointers. But everytime the data is overwriting with most recent data. Please check my code

 TCHAR nameBuffer[256]; //Globally Declared

 void Caller()
 {
 TCHAR* ptszSecondInFile= QStringToTCharBuffer(userName);
 TCHAR* ptszOutFile=QStringToTCharBuffer(Destinationfilename);
 }

TCHAR *dllmerge::QStringToTCharBuffer( QString buffer )
{
    memset(nameBuffer, 0, sizeof(nameBuffer));
#if UNICODE
_tcscpy_s(nameBuffer, _countof(nameBuffer), buffer.toUtf8());
#else
_tcscpy_s(nameBuffer, _countof(nameBuffer), buffer.toLocal8Bit());
#endif
_tprintf( _T( "nameBuffer %s\n" ), nameBuffer );
return nameBuffer;
 }

I am gettting ptszSecondInFile and ptszOutFile both same answer. Is it possible to do with TCHAR* nameBuffer[256];

© Stack Overflow or respective owner

Related posts about c++

Related posts about c