Questions tagged [unsigned-char]
321 questions
0
votes
4 answers
C++ conversion from unsigned char to std::string
Intro: Consider that I have no experience with C++, but can find my way around any language to do basic tasks.
Most of my experience is with .net languages (vn.net and C#), php and js, so please explain as if you were teaching a complete noob.
Here…

Tomislav Plečko
- 167
- 2
- 14
0
votes
2 answers
unsigned char array from c++ in c#
I'm trying to call a C++ dll function in C#.
The function has a struct as a parameter and I have a problem with the variable aby_data[8]. I defined the unsigned char[] as a byte[], the program doesn't crash but I don't receive any data.
Struct…

marc29
- 21
- 5
0
votes
2 answers
How to convert 16 bit unsigned int to 8 bit unsigned char & finally return in an unsigned char*?
I have a vector of 8 bit unsigned chars & a vector of 16 bit unsigned shorts
std::vector eight_bit_array;
std::vector…

TheWaterProgrammer
- 7,055
- 12
- 70
- 159
0
votes
2 answers
Understanding C Requirements of bits and offset
I understand the general idea of C and how making a log file would go. Reading/writing to a file and such.
My concern is the following format that is desired:
[![enter image description here][1]][1]
I've gotten a good chunk done now but am concerned…

Jack Tom
- 19
- 2
0
votes
0 answers
Base64 string to byte array (unsigned char*) objective-c
I need to convert Base64 string to Byte array (unsigned char*):
I tried this way, but it return half byte (Hex decimal) value in every array field.
My code:
NSMutableString *Results = "base64 data";
NSData *decodedData = [[NSData alloc]…

Yasser Ajaj
- 119
- 1
- 10
0
votes
2 answers
Sum-reducing an array of unsigned char with CUDA: how to properly accumulate thread-block results with uchars?
Relying on NVIDIA's samples and on some good advice found here at SO, I have been managing to implement a few array-reduction kernels that I need for my project. However, one particular issue remains causing me trouble. It is, how to properly do…

RAs
- 377
- 3
- 13
0
votes
1 answer
C++ - Convert float to unsigned char array and then back to float
When I try to convert a float to an unsigned char array and then back to a float, I'm not getting the original float value. Even when I look at the bits of the float array, I'm seeing a bunch of different bits set than what were set originally.
Here…

Programmer_D
- 601
- 2
- 15
- 27
0
votes
4 answers
C++: getting a fact size of data in uchar/guchar?
The problem is simple: sizeof((u_char)value) returns 8. strlen fails. How to get a length of uchar's content?
Attempted
std::cout << "Data: " << (u_char *)data[0] << "\n"`;
u_char is defined in include/sys/*.h as unsigned char;

kagali-san
- 2,964
- 7
- 48
- 87
0
votes
1 answer
Is there a way to directly read a number from file to unsigned char variable?
As in reading "117" in a text file and giving the variable value 'u', not '1'. And I know I can do it simply and quickly by reading the value to an int and then casting it to unsigned char, I just need to know if I can do it directly.

user3019593
- 37
- 4
0
votes
1 answer
C++ cast char * to unsigned char
I am working in a c++ project where I have to use < openssl/sha.h> and I am using in particular the SHA1 function. My problem is, that the function receives unsigned char[], and I need to get processed parameters passed as arguments to the…

9uzman7
- 409
- 8
- 19
0
votes
2 answers
ifstream::read not reading unsigned char, even with reinterpret_cast
I am trying to get my code to read a PPM image (P3) and it isn't working as it should. The idea is to get a 3 unsigned chars and store them in RGB. But at the moment it is only resulting in taking the first character and ignoring the rest.
Image…

Alexander Shuev
- 105
- 10
0
votes
1 answer
Null pointer with unsigned char in c
I'm constructing an unsigned char * in c and I want to know how I finish it. So usually at the end of my memories I put '\0' but unsigned char recognize it as a 0.
so when I do something like that :
void complement(unsigned char *c, int n){
…

Jackie
- 143
- 1
- 3
- 8
0
votes
2 answers
c++ reading argv into unsigned char fixed size: Segmentation fault
I am trying to read command line argument into a fixed size unsigned char array. I get segmentation fault.
My code:
#include
#include
#include
#include
unsigned char key[16]={};
int main(int argc, char**…

algoProg
- 718
- 2
- 11
- 27
0
votes
0 answers
C - convert unsigned char to signed integer (negative values)
I have an unsigned char with binary value 11010001.
If I were to convert it to unsigned integer its value would be 209. Its signed value however should be -81.
If I normally convert it to integer by type casting it gives me a value of 209, but I…

The Prenx
- 483
- 4
- 15
0
votes
3 answers
Value of a+b and char type
I am working in C++ and I had (as an exercise) to write on paper 2 answers.
The first question: if we have the following declarations and initialisations of variables:
unsigned char x=250, z=x+7, a='8';
What is the value of the…

shibuya
- 3
- 3