Questions tagged [unsigned-char]
321 questions
-4
votes
1 answer
Convert hex numbers from unsigned char to string
I have an array of unsigned chars with hex values and I need to make a string of them. So when I have arr[0]=2b and arr[1]=fc I want to be able to make a string s="2bfc", not the characters from ascii codes. How can I do that?

M-guy
- 1
- 1
-5
votes
1 answer
How come the output of this C program is 1?
#include
int main() {
unsigned char c = (int) 0.54;
for(; c++; printf("%d", c));
printf("%d", c);
return 0;
}
And when I run the program the output is displayed as 1
How can the output be 1? Thanks in advance
-5
votes
2 answers
Why can't I assign a function to a variable?
If I have the following code example:
#include
using namespace std;
unsigned char Receive(void){
unsigned char q[4] = {0x0B, 0x0B, 0x0B, 0x0B};
return q;
}
void Transmit(){
unsigned char a[4];
a = Receive();
}
int…

user164324
- 5
- 3
-5
votes
1 answer
How do I declare a static const char array in Swift?
I need to convert following code to Swift
static const char gSalt[] =
{
(unsigned char)0xf4, (unsigned char)0x28, (unsigned char)0x32, (unsigned char)0xab,
(unsigned char)0x4b, (unsigned char)0xa1, (unsigned char)0xcc, (unsigned…

Muhammad Aamir Ali
- 20,419
- 10
- 66
- 57
-6
votes
2 answers
How to assign a hexadecimal value to an unsigned char variable in a C program
The hexadecimal value that I want to store in a variable is of length 32.
"DC4938C31B9E8B30F32FC0F5EC894E16".
I also want to then print this value but I don't know the format specifier in printf for unsigned char.

Manas
- 84
- 2
- 7
-7
votes
1 answer
How to represent unsigned char values as hexadecimal string?
I want to convert an unsigned char arrays content to a hexadecimal string representation.
Can anyone help with a function or a way out?
unsigned char codeslink[5] ={ 0x33, 0x74, 0x74, 0x73, 0x72};
std::string my_std_string(reinterpret_cast

DavidoLLP
- 45
- 8