Questions tagged [unsigned-char]
321 questions
-2
votes
1 answer
C memcpy unsigned char to 1 element unsigned char array for checksum calculation
There is a char array ACKbuffer[2] so I first cast to unsigned char the element that I want but it's giving me an error when I try to memcpy it to an unsigned char array.
//first element is checksum
unsigned char ack_csum;
ack_csum = (unsigned…

mLstudent33
- 1,033
- 3
- 14
- 32
-2
votes
1 answer
warning about strlen() on BYTE type
I am trying to compute the hash value of some words using sha256, but when I use sha256_update() function,
typedef unsigned char BYTE;
BYTE text1[] = {"abcd"};
sha256_update(&ctx, text1, strlen(text1));
use strlen() on BYTE type will give me some…

Vincent Zhou
- 141
- 2
- 10
-2
votes
1 answer
memcpy from unsigned char * to unsigned int
I am not sure what the following C++ code does (I have replaced parts that don't matter with dots):
unsigned char* p = ...;
unsigned int metaNum;
memcpy( &metaNum, p, sizeof( unsigned int ) );
p += sizeof( unsigned int );
for ( unsigned int m = 0;…

mgus
- 808
- 4
- 17
- 39
-2
votes
4 answers
C++ Converting a String to unsigned char and convert it back to get the string
I hope I have clearly stated my goal in the topic and following is the code I am using.
#include
#include
#include
using namespace std;
int main() {
const char *data_ptr =(char*)"test";
const uint8_t* p =…

Tharanga
- 2,007
- 4
- 32
- 50
-2
votes
1 answer
Is it a way to define maximum of an unsigned char to a specific value n C?
I want to define maximum of a char in my program to 5. Is it a way to achieve this without controlling each time with 5.

electro103
- 147
- 6
-2
votes
2 answers
Keyboard input on unsigned char?
uchar szPlaintext[128]; //dato da criptare
cout << "\nInserisci testo : ";
getline(cin, szPlaintext);
I tried it with a getline (cin, szPlaintext); but I have a lot of errors. I compile with VS2015.
Premise that I am trying…

Pietro Ariano
- 113
- 1
- 2
- 12
-2
votes
2 answers
Standard Input for Unsigned Character
I am trying to send unsigned characters through a program, and I would like to be able to get the numbers through standard input (ie std::cin). For example when I type 2 I would like it send ☻ (unsigned char 2). when I use the code:
std::cout <<…

jeffpkamp
- 2,732
- 2
- 27
- 51
-2
votes
2 answers
How i can convert unsigned char* to image file (like jpg) in c++?
I have a opengl application that create one texture in format unsigned char*, and i gotta save this texture in one image file, but a don't know how to do. can someone help me?
this is my creation of this texture:
static unsigned char*…

user3651443
- 29
- 1
- 11
-2
votes
1 answer
c++ unsigned char memory copy
I need to pass an unsigned char array from one method to another, and i tried using this code:
{
unsigned char *lpBuffer = new unsigned char[182];
ReceiveSystemState(lpBuffer);
}
BOOL ReceiveSystemState(unsigned char *lpBuffer)
{
…

MRM
- 561
- 5
- 12
- 29
-3
votes
1 answer
Unsigned Char Concat In C
im trying to convert a string message to hex value in C.
For example if i have a message like "abc" i want to have it by 162636 etc. My code is below. In this code, i have to do some concat operation to store them all but now i can store only 36.…

Berkin
- 1,565
- 5
- 22
- 48
-3
votes
1 answer
How to parse captured packet from socket in cpp?
I'm using RAW socket to capture udp packets. After capturing I want to parse the packet and see what's inside.
The input I get from the socket is an unsigned char* buffer and it's length. I tried to put the buffer into a string but I guess I did it…

user3206874
- 795
- 2
- 7
- 15
-3
votes
1 answer
unsigned char array of 8 bits to unsigned char
I've created a function that turns an unsigned char into an unsigned char array of size 8 (where each index contains either 0 or 1, making up the 8 bits of the given char). Here is the 100% working version:
unsigned char * ucharToBitArray(unsigned…

David Baez
- 1,208
- 1
- 14
- 26
-4
votes
4 answers
How can I do arithmetic on numbers with a non-standard binary representation?
With unsigned char you can store a number from 0 to 255
255(b10) = 11111111(b2) <= that's 1 byte
This will make it easy to preform operations like +,-,*...
Now how about:
255(b10) = 10101101(b2)
Following this method will make it…

Jonas
- 1,019
- 4
- 20
- 33
-4
votes
1 answer
'unsigned short var' vs 'unsigned char var [2]' in C++
In C++, I can declare a variable as either an unsigned short or an unsigned char (with 2 bytes) as shown below. However, is there any differences?
unsigned short p;
unsigned char q[2];

Habibie
- 11
- 2
-4
votes
3 answers
when assigning the unsigned char with the integer greater than 255 it gives the different output , why?
#include
int main()
{
unsigned char c =292;
printf("%d\n",c);
return 0;
}
The following code gives the output "36".
I wanted to know why this happens?

umair saifullah
- 47
- 2
- 9