Solved

Wide Char Null Terminator

Posted on 2006-06-13
5
443 Views
Last Modified: 2008-02-01
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
Comment
Question by:cophi
5 Comments
 

Author Comment

by:cophi
ID: 16893646
sorry the ;&52685 looked like boxes when I copy'd them into there
0
 

Expert Comment

by:BaluVasudev
ID: 16893701
Psot peice of code here
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 400 total points
ID: 16893754
wchar_t* array;
...

array[5] = 0;
0
 
LVL 14

Assisted Solution

by:wayside
wayside earned 100 total points
ID: 16893774
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
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 16894431
Can you post yur code ?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now