Solved

convert unsigned char[] to const char

Posted on 1998-07-10
4
1,828 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
ID: 1318998
Cast it like
SetDlgItemText(IDC_STATIC, (const char*)label);
0
 
LVL 2

Expert Comment

by:VEngineer
ID: 1318999

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
ID: 1319000
worked like a charm!
thanx
0
 
LVL 3

Expert Comment

by:Norbert
ID: 1319001
what is the adtvantage usining static_cast ?
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 178
Windows Drag & Drop Location 2 100
Error on moodle after upgrade 3 130
sum28 challenge 31 112
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

810 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