Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Wide Char Null Terminator

Posted on 2006-06-13
5
Medium Priority
?
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1600 total points
ID: 16893754
wchar_t* array;
...

array[5] = 0;
0
 
LVL 14

Assisted Solution

by:wayside
wayside earned 400 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

671 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