Questions tagged [unsigned-char]
321 questions
1
vote
2 answers
In Python, how can I convert an integer between 0 and 255 to a single unsigned byte?
My laptop runs a Python program that reads a joystick to send a speed command to an Arduino that in turn controls the motor on a toy car. To do that the program converts an integer with values between 0 and 255 to a single unsigned byte that it…

Daanii
- 259
- 2
- 3
- 12
1
vote
1 answer
Should I use signed char for characters with negative values if I target portability?
A char data type is not guaranteed to be signed, which means on some implementations it is signed, and on others it is unsigned. So why do people always ignore the signed qualifier?
char c = 'C'; // can be signed or unsigned
signed char sc = 'D';…

Maestro
- 2,512
- 9
- 24
1
vote
1 answer
storing 0 in a unsigned char array
I have a unsigned char array like this:
unsigned char myArr[] = {100, 128, 0, 32, 2, 9};
I am using reinterpret_cast to covert it to const char* as I have to pass a const char* to a method. This information is then sent over grpc and the other…

Purdgr8
- 33
- 1
- 7
1
vote
0 answers
CPP: Convert unsigned char* to std::vector
I have an array of unsigned chars ( unsigned char *), how can I convert it to a vector of unsigned chars? ( std::vector )?

Kidsm
- 308
- 2
- 14
1
vote
1 answer
Opening a .pak file using fopen and making that file apply to a const unsigned char* (C++)
I'm trying to upload a file (.pak file) using fopen, read it and make it equal blockStorage.
What I'm doing right now doesn't work, I think because pfile.data() doesn't even exist (it's left over from something I was trying and stopped doing because…

Erasto Paula
- 21
- 2
1
vote
2 answers
Cout unsigned char
I'm using Visual Studio 2019: why does this command do nothing?
std::cout << unsigned char(133);
It literally gets skipped by my compiler (I verified it using step-by-step debug):
I expected a print of à.
Every output before the next command is…

Simo Pelle
- 141
- 1
- 11
1
vote
2 answers
Showing undefined reference to a defined object
I'm trying to Hash few strings in my project. And i'm using following project that uses HAMC SHA1 algorithm
http://www.codeproject.com/KB/recipes/HMACSHA1class.aspx
I was able to compile the whole code after lots of trouble. But in the end i'm left…

VinayJ
- 11
- 3
1
vote
3 answers
unsigned char rotate
I'm a little bit confused as to what an unsigned char is. A signed char is the representation of the char in bit form right? A sample problem has us rotating to the right by n bit positions, the bits of an unsigned char with this solution:
unsigned…

raphnguyen
- 3,565
- 18
- 56
- 74
1
vote
4 answers
How to append char data to a std::vector without causing a copy
I have a vector of chars which contains some data elements.
std::vector data_1;
I have an unsigned char * which is pointing another set of data elements.
unsigned char * data_2;
Question:
Is there a way I can merge data_2 into…

AdeleGoldberg
- 1,289
- 3
- 12
- 28
1
vote
1 answer
Why does my ofstream write result in more bytes than expected?
Edit 1: I've identified the hex combination that triggers this problem but still can't fix it. See Edit at bottom:
Original Post: I'm trying to pass data from a sensor to a binary file. I'm using the manufacturer's example code and DLL to grab 4096…

Wick
- 304
- 1
- 11
1
vote
1 answer
How to use setfill and setw to stock an hex value in a string variable
I read a file and transform it to hex notation like this {0x4D,x0FF,0x01}
I stock it in an unsigned char array.
I can print what I would like to stock but I don't achieve to stock datas in my array.
I read the bitset class documentation but I am not…

Timtim45687
- 13
- 7
1
vote
2 answers
meaning and debuging (print) of uint8_t* value in c++
Let say I have some data (for example numbers representing pixels of a grey image) that are read from a file and packed into a pointer to uint8_t.
uint8_t* data = getData(readFile(filePath));
If I truly understood what a uint8_t pointer is, it is…

Gaetan
- 577
- 2
- 7
- 20
1
vote
1 answer
Need to understand memory management when using "unsigned char" to point to raw data buffer
My question is in the code below. I'd like to understand if there's such a thing as "retaining" when it comes to "unsigned char" pointers. Please explain.
// MyObject.h
@interface myObject : NSObject {
unsigned char *myData;
}
//…

anna
- 2,723
- 4
- 28
- 37
1
vote
1 answer
C# Marshaling Unsigned Char Return Value from C++ DLL
I am importing functions from a C++ DLL into a C# application. I am able to import and some of the functions but not others. The C++ DLL came with a C++ project that shows how to use it from C++. I want to replicate this in C# but I'm having…

S. Lacy
- 51
- 7
1
vote
2 answers
In C11, string literals as char[], unsigned char[], char* and unsigned char*
Usually string literals is type of const char[]. But when I treat it as other type I got strange result.
unsigned char *a = "\355\1\23";
With this compiler throw warning saying "pointer targets in initialization differ in signedness", which is…

user150497
- 490
- 4
- 14