Questions tagged [unsigned-char]
321 questions
0
votes
1 answer
Grabbing bit 1 and 6, and 2 through 5 in an unsigned char in C
I have an unsigned char at 6 bytes long.
The value being stored within the char is:
Hex: 53167DFD95B7
Binary: 010100 110001 011001 111101 111111 011001 010110 110111
What I need to do is capture bit 1 and bit 6. Then convert that to a decimal. Then…

TyrantUT
- 29
- 1
- 5
0
votes
2 answers
Convert an int array to an unsigned char array for AES encryption
I got an array
int key[128] = {1,0,1,0,0,1, .........., 0,1,0}
I want to convert this array to
unsigned char key1[16] = {0x__,0x__,...,0x__}
for example if
from key[0] to key[7] is 10100011, then key1[0] = 0xa3
I need use this new array for AES…

FrankeyYuan
- 43
- 1
- 4
0
votes
1 answer
Trying to copy cv::Mat data into uchar *
I am trying to copy the data of a openCV mat object (its of type uchar*) into an unsigned char* using copy function of c++ as follows:
cv::Mat m = cv::imread (path, 0);
uchar * ptr;
std::copy (m.data, ptr, mask.size);
However im getting 26 syntax…

dramaticlook
- 653
- 1
- 12
- 39
0
votes
1 answer
Can't use boost::stream with std::string to instanciate boost::binary_oarchive or boost::binary_iarchive
Cheer developer,
i have got trouble with the next code (visual studio 2015 compiler):
template
inline void Serialize::IntoStringBuffer(const SERIALIZABLE_TYPE& object, BUFFER_TYPE& strBuffer)
{
…

PVO
- 31
- 4
0
votes
2 answers
When converting NSData to unsigned char*, I get the wrong result
I would like to convert an UIImage into unsigned char*. First I convert UIImage into NSData, then NSData to unsigned char*. I use the following method to convert NSData to unsigned char*:
unsigned char *binaryData = (unsigned char *)[imageData…

Jenny Cheung
- 301
- 2
- 5
- 12
0
votes
1 answer
Two questions with base64 encoding
I confused how to convert const char * to base64 with 2 Questions:
Question #1 how do I defined the length of output string that would perfectly match the length of output base64?I have found a code which from apple opensource,the code in below …

Ken Yup
- 35
- 6
0
votes
3 answers
In Java,how to simulate "converting negative numbers casted by unsigned char in c"?
for example, in c, converting -1234 to unsigned char would become 46:
int main(){
int a=-1234;
unsigned char b=a;
printf("%d\n",b);
return 0;
};
I want to convert the code to java version, now the code is:
public class Test{
…

ggrr
- 7,737
- 5
- 31
- 53
0
votes
2 answers
different answers of scanf of a char with %d and %c
This is a program used for swapping the nibbles of a byte, which is perfect for a byte but I faced a problem.
Code:
#include
void main()
{
unsigned char a = 0;
scanf("%d", &a);
a = ((a << 4) | (a >> 4));
printf("the…

augustine nishil
- 19
- 6
0
votes
0 answers
UIImage to unsigned char byte array
I am working at printing an image to a thermal printer. The image needs to be converted into an unsigned char buffer. For example
unsigned char buffer[10]={0x55,0x66,0x77,0x88,0x44, 0x1B,0x58,0x31,0x15,0x1D}
So far I can covert the image to a…

Duncan Shingleton
- 21
- 7
0
votes
1 answer
How to copy ULONG into PUCHAR
Today I am trying to copy a unsigned long variable into the contents of an unsigned char * variable.
The reasoning for this is, I wrote an RC4 cipher which requires the key input to be a unsigned char *, I am using the SYSTEMTIME class to obtain a…

Andrew Peters
- 79
- 1
- 10
0
votes
1 answer
Connecting std::basic_ofstream to a FIFO. bad_cast exceptions
Using gcc 4.4.3 on Linux 2.6.32, I get bad_cast exceptions when connecting std::basic_ofstream to a FIFO.
Stepping though the debugger, I can see that the error is generated at various places in the standard library because the _M_codecvt member of…

Mike B
- 303
- 4
- 13
0
votes
1 answer
not correct print with unchar Mat for image 8UC1 c++
Could help somebody please ?
I have an image after Canny detector, the type is 8UC1, when i want to access to the values, cout gives to me ? (Test Canny�), so my code is following:
Mat src;
/// Load an image
src = imread( argv[1] );
if( !src.data…

Viktoriia
- 85
- 1
- 2
- 10
0
votes
2 answers
Comparing SHA Checksum values in C
I am working on an assignment for creating a shell in C. The program have to read a config file, where the commands that are allowed in the shell are listed. Also in this config file, for every command that is allowed, it's sha1 checksum value is…

Neo
- 349
- 5
- 18
0
votes
1 answer
Print unsigned char array to hex
The problem
I've got some byte buffer, that get's filled during runtime. I want to display the buffer's content, using hex-code. So this is the definition of the buffer:
enum { max_data_length = 8192 }; //8KB
unsigned char…

Peter
- 394
- 7
- 20
0
votes
1 answer
C - unsigned char in a struct
Can someone please explain to me the reason I get different results in the output?
I have defined a list using list nodes:
typedef struct list_node
{
unsigned char letter;
struct list_node *next;
} ListNode;
typedef struct…

mike
- 767
- 2
- 10
- 18