about wstring
-
Hi Friends Please see the following code
wstring str1 = L"Test"; wchar_t* buffer = new wchar_t[str1.length()+2]; wcscpy(buffer, str1.c_str());
Now here How much bytes extra I need to allocate for buffer for '\0' terminating character? +2 or +1? - Vikram S -
Hi Friends Please see the following code
wstring str1 = L"Test"; wchar_t* buffer = new wchar_t[str1.length()+2]; wcscpy(buffer, str1.c_str());
Now here How much bytes extra I need to allocate for buffer for '\0' terminating character? +2 or +1? - Vikram SYou only need one extra element to hold '\0' because you're allocating with type wchar_t which is two bytes in size
-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts
-
You only need one extra element to hold '\0' because you're allocating with type wchar_t which is two bytes in size
-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts
yes got it. Thanks
-
Hi Friends Please see the following code
wstring str1 = L"Test"; wchar_t* buffer = new wchar_t[str1.length()+2]; wcscpy(buffer, str1.c_str());
Now here How much bytes extra I need to allocate for buffer for '\0' terminating character? +2 or +1? - Vikram Scompiler will itself take care of sizeof NULL, you just have to allocate only 1 extra space to wchar_t
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You