Click here to Skip to main content
15,885,365 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: The problem with Serial library for C++ Pin
LongDuyTran13-Nov-11 20:05
LongDuyTran13-Nov-11 20:05 
AnswerRe: The problem with Serial library for C++ Pin
Richard MacCutchan13-Nov-11 22:37
mveRichard MacCutchan13-Nov-11 22:37 
AnswerRe: The problem with Serial library for C++ Pin
Erudite_Eric13-Nov-11 22:50
Erudite_Eric13-Nov-11 22:50 
AnswerRe: The problem with Serial library for C++ Pin
OneKey2Press17-Dec-11 2:49
OneKey2Press17-Dec-11 2:49 
QuestionBuilding a WCHAR Array, Not sure if it right Pin
jkirkerx11-Nov-11 7:05
professionaljkirkerx11-Nov-11 7:05 
AnswerRe: Building a WCHAR Array, Not sure if it right Pin
Mark Salsbery11-Nov-11 7:51
Mark Salsbery11-Nov-11 7:51 
GeneralRe: Building a WCHAR Array, Not sure if it right Pin
jkirkerx11-Nov-11 8:12
professionaljkirkerx11-Nov-11 8:12 
AnswerRe: Building a WCHAR Array, Not sure if it right Pin
Richard MacCutchan11-Nov-11 22:48
mveRichard MacCutchan11-Nov-11 22:48 
Try this:
C++
// first go through the names calculating how much space we need
int length = 0;
for ( int i = 0; i < sqlCount; ++i )
{
    length += wcslen(sqlSrvCollection[i]);
    length += 1;    // don't forget to add one for the trailing null
}
// allocate a buffer big enough to hold the strings
WCHAR* pzServerNames = new WCHAR[length + 1];    // plus the very final extra null
PWSTR pNext = pzServerNames;    // a temporary pointer
// now go through copying each string to the array buffer
for ( int i = 0; i < sqlCount; ++i )
{
    wcscpy_s(pNext, length, sqlSrvCollection[i]);    // copy the next name into the array
    int nlen = wcslen(sqlSrvCollection[i]);          // get its length
    pNext += nlen;                                   // move the pointer forward
    *pNext++ = L'\0';                                // add the null (incrementing the pointer)
    length -= nlen + 1;                              // reduce amount of space left
}
*pNext = L'\0';    // add the final trailing null

Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman



GeneralRe: Building a WCHAR Array, Not sure if it right Pin
jkirkerx12-Nov-11 7:01
professionaljkirkerx12-Nov-11 7:01 
GeneralRe: Building a WCHAR Array, Not sure if it right Pin
jkirkerx12-Nov-11 9:17
professionaljkirkerx12-Nov-11 9:17 
GeneralRe: Building a WCHAR Array, Not sure if it right Pin
Richard MacCutchan12-Nov-11 21:36
mveRichard MacCutchan12-Nov-11 21:36 
AnswerRe: Building a WCHAR Array, Not sure if it right Pin
David Crow14-Nov-11 2:39
David Crow14-Nov-11 2:39 
QuestionVC 6.0 MFC MDI new frame / view without caption erases Windows → New titles Pin
Vaclav_11-Nov-11 3:09
Vaclav_11-Nov-11 3:09 
AnswerRe: VC 6.0 MFC MDI new frame / view without caption erases Windows → New titles Pin
Richard MacCutchan11-Nov-11 5:27
mveRichard MacCutchan11-Nov-11 5:27 
GeneralRe: VC 6.0 MFC MDI new frame / view without caption erases Windows → New titles Pin
Vaclav_11-Nov-11 6:09
Vaclav_11-Nov-11 6:09 
GeneralRe: VC 6.0 MFC MDI new frame / view without caption erases Windows → New titles Pin
Richard MacCutchan11-Nov-11 6:38
mveRichard MacCutchan11-Nov-11 6:38 
QuestionBeginner with C++ - Need helps with overload member function error Pin
LongDuyTran10-Nov-11 19:21
LongDuyTran10-Nov-11 19:21 
AnswerRe: Beginner with C++ - Need helps with overload member function error Pin
Chuck O'Toole10-Nov-11 20:30
Chuck O'Toole10-Nov-11 20:30 
GeneralRe: Beginner with C++ - Need helps with overload member function error Pin
LongDuyTran11-Nov-11 2:19
LongDuyTran11-Nov-11 2:19 
AnswerRe: Beginner with C++ - Need helps with overload member function error Pin
Chuck O'Toole11-Nov-11 4:41
Chuck O'Toole11-Nov-11 4:41 
GeneralRe: Beginner with C++ - Need helps with overload member function error Pin
krmed11-Nov-11 7:05
krmed11-Nov-11 7:05 
AnswerRe: Beginner with C++ - Need helps with overload member function error Pin
Stefan_Lang11-Nov-11 2:17
Stefan_Lang11-Nov-11 2:17 
QuestionWindows has triggered a breakpoint in xxxxx, This may be due a corruption of the heap Pin
sdancer7510-Nov-11 7:55
sdancer7510-Nov-11 7:55 
AnswerRe: Windows has triggered a breakpoint in xxxxx, This may be due a corruption of the heap Pin
Richard Andrew x6410-Nov-11 8:35
professionalRichard Andrew x6410-Nov-11 8:35 
GeneralRe: Windows has triggered a breakpoint in xxxxx, This may be due a corruption of the heap Pin
sdancer7510-Nov-11 9:26
sdancer7510-Nov-11 9:26 

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.