Solved

Wide Char Null Terminator

Posted on 2006-06-13
5
445 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

777 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