• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1917
  • Last Modified:

convert unsigned char[] to const char

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
Soth
Asked:
Soth
  • 2
1 Solution
 
NorbertCommented:
Cast it like
SetDlgItemText(IDC_STATIC, (const char*)label);
0
 
VEngineerCommented:

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

SetDlgItemText(IDC_STATIC, static_cast<const char*>(label) );
0
 
SothAuthor Commented:
worked like a charm!
thanx
0
 
NorbertCommented:
what is the adtvantage usining static_cast ?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now