Solved

Wide Char Null Terminator

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

839 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