Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

Wide Char Null Terminator

I have a Wide Char which lets say has 5 characters in it, but then its appended with all these junk characters.  So for exampe "stuff췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍췍"
I want to append a null terminator after the f so I can get rid of all these characters.  
How do I go about this?
0
cophi
Asked:
cophi
2 Solutions
 
cophiAuthor Commented:
sorry the ;&52685 looked like boxes when I copy'd them into there
0
 
BaluVasudevCommented:
Psot peice of code here
0
 
AlexFMCommented:
wchar_t* array;
...

array[5] = 0;
0
 
waysideCommented:
52685 is also 0xCDCD, which is a marker for uninitialized memory.

So I am guessing that you allocated an array and then copied the string into it somehow:

wchar_t * pStr = new wchar_t[100];

pStr[0] = L's';
pStr[1] = L't';
pStr[2] = L'u';
pStr[3] = L'f';
pStr[4] = L'f';

To set the NULL, just set the next character to 0:

pStr[5] = 0;

Or you could initialize the whole array to zeros:

ZeroMemory(pStr, 100*sizeof(wchar_t));

We need to see your actual code to give more advice.


0
 
rajeev_devinCommented:
Can you post yur code ?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now