Solved

convert unsigned char[] to const char

Posted on 1998-07-10
4
1,808 Views
Last Modified: 2013-11-19
just say I have the following variable defined as:

unsigned char label[32];

now in my program i want to call the following:
SetDlgItemText(IDC_STATIC, label);

but this gives the error:
"cannot convert parameter 2 from unsigned char[32] to const char *"

so how can I convert my unsigned char label[32] to a const char *??

0
Comment
Question by:Soth
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Norbert earned 100 total points
Comment Utility
Cast it like
SetDlgItemText(IDC_STATIC, (const char*)label);
0
 
LVL 2

Expert Comment

by:VEngineer
Comment Utility

Using the standard C++ casting operator 'static_cast' instead of old C style cast notation:

SetDlgItemText(IDC_STATIC, static_cast<const char*>(label) );
0
 

Author Comment

by:Soth
Comment Utility
worked like a charm!
thanx
0
 
LVL 3

Expert Comment

by:Norbert
Comment Utility
what is the adtvantage usining static_cast ?
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

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

16 Experts available now in Live!

Get 1:1 Help Now