Questions tagged [unsigned-char]
321 questions
0
votes
1 answer
C++ unsigned char *{varName}; -> C#
I have DLL written in C++. I need to use it in my C# code
I am trying to make such object of C++ in C#:
typedef struct {
int width;
int height;
int stride;
unsigned char *pixels;} FIS_Image;
Does unsigned char *pixels; in C++ will be byte pixels;…

Komiljon Aliyev
- 89
- 1
- 7
0
votes
1 answer
How do I convert an unsigned char buffer to a double in C++?
I am trying to convert an unsigned char buffer array into a double.
Why does this not copy the bytes into the double as they are in the array?
#include
#include
int main() {
unsigned char buffer[8] = {63, 240, 0, 0, 0, 0,…

Dylan Meiners
- 31
- 6
0
votes
2 answers
Get length of unsigned char*
Hi i am trying to get the length of unsigned char*, it is a pointer to a array witch means i cant use sizeof. I cant cast it to char* then do strlen() either, seeing as it contains null bytes in the middel of the string. What other way is there to…

raketmus
- 48
- 6
0
votes
3 answers
How do I prevent this infinite loop
When I run the following code, sometimes it will exit successfully and sometimes it will enter an infinite loop if highestNum is equal to 255. I understand that this happens because of rollover when 255 gets incremented and becomes 0. I understand…

Jacob Walters
- 77
- 2
- 7
0
votes
1 answer
why is 00000000 - 00000001 = 11111111 in C unsigned char data type?
I observed that, when a unsigned char variable stores the value 0 (000000002) and it gets decremented by 1 (000000012), the variable value turns into 255 (111111112), which is the highest value that a unsigned char variable can hold.
My question is:…

samuel
- 3
- 3
0
votes
1 answer
reverse a string using pointers (have to use unsigned *char) in C
I am currently working on an assignment for Uni.
The task is to reverse a string in a separate function. The function-name is given like that:
void string_rev(unsigned char *str);
My Solution looks like this:
void string_rev(unsigned char *str){
…

Easymoney_
- 13
- 2
0
votes
2 answers
Convert a string to and unsigned char []
I currently have a Packet set up like so:
struct Packet {
unsigned short sequenceNumber;
unsigned short length;
unsigned char control;
unsigned char ack;
unsigned short crc;
unsigned char data[];
Packet copy(const Packet&…

Jeff Schmitz
- 1,087
- 1
- 13
- 28
0
votes
2 answers
Change uint8_t* to char*?
I have an API which requests a char*, this is my API function:
CANMessage(unsigned _id, const char* _data, char _len = 8)
More information available here: https://os.mbed.com/docs/mbed-os/v5.11/mbed-os-api-doxy/classmbed_1_1_c_a_n_message.html
I…

Eskey Eski
- 97
- 6
0
votes
2 answers
Print/store n bytes of u_char pointer in c?
I am trying to make a function to print/store the first n bytes of an u_char pointer. This is what I currently have (just trying to print the first value), but it doesn't work.
void print_first_value(const u_char * p) {
printf("%d", p[0]);
}
I…

Citut
- 847
- 2
- 10
- 25
0
votes
1 answer
Difference between unsigned short and unsigned char in LoRa communication
I am working on establishing a lora communication between a gateway (RPI3 + LoRa hat) and a node (RPi3 + LoRa hat). As I would like to establish the communication channel without TTN, I tried the following example to setup communication between the…

Tina S
- 1
0
votes
1 answer
How to load strings into elements of BYTE* array (C++)
I have a program that takes the contents of a file and convert it into a hex. I would like to take those hex values and store them as elements of an unsigned char array I've called hexData. How would I go about this?
I've tried converting the hex…

Shayon Shakoorzadeh
- 13
- 3
0
votes
1 answer
Convert unsigned char to string then again to unsigned char
I want to convert:
A simple unsigned char [] to string
Then again to unsigned char
This is my code:
// This is the original char
unsigned char data[14] = {
0x68,0x65,0x6c,0x6c,0x6f,0x20,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x72,
};
// This…
user9411840
0
votes
1 answer
Convert System::String^ into unsigned char*
I have a C++-Dll which I am calling from a C# project. In a function I need a string as a parameter and then convert it to an unsigned char*. I am using System.String^ to convert the C#-String to a C++-String. How can I convert the String^ to an…

User987123
- 97
- 1
- 11
0
votes
4 answers
unsigned char pointer in C#?
In the middle of translating some code from C++ to C#, I found this,
unsigned char *p = m_pRecvBuffer + 5;
unsigned int noncelen1 = *p * 256 + p[1];
How do I translate this into C#? m_pRecvBuffer is a char-array, however I store it as a byte-array.

Viktor Elofsson
- 1,581
- 2
- 13
- 20
0
votes
1 answer
Convertion from ByteArray to unsigned char*
i'm in Qt and i dhave the following problem: I'm storing a fingerprint template from a embedded system, after sending a command thru ftp, my system get fingerprint from scan and save the template (as unsigned char*) i do know the size of the…
user8057102