Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Work with UNICODE

Status
Not open for further replies.

newtron

Programmer
Mar 11, 2010
2
GE
Hello everybody,
can anyone help me? :S

how can I get only one character from
WCHAR *str = L"string";
for example only "r", when I'm typing this
MessageBox(NULL,&str[3],NULL,NULL);
it gets "ring" and not "r"

please help me ...
 
That is because you are using a null-terminated string and passing a pointer to the third character of the string. In doing that it considers the third character onward your string.

Consider assigning Str[3] to a CHAR variable.

I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy
 
I know how works char variable, but I want to assign it in UNICODE, because of this I wrote there WCHAR.
can you help me to solve this problem? :S
 
The MessageBox function 2nd parameter "Points to a null-terminated string containing the message to be displayed".

Well, make this home-made null-terminated Unicode (WCHAR) string (what's a problem?) and enjoy:
Code:
WCHAR *str = L"string";
...
WCHAR chr3[2] = {str[3]};

MessageBox(NULL,chr3,NULL,NULL);
// Now you are free:
chr3[0] = str[4]; ...
and so on...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top