Questions tagged [unsigned-char]

321 questions
3
votes
1 answer

C++ from unsigned char* to stringstream: Segmentation fault (core dumped) error

I am writing a C++ code and trying to convert an unsigned char* array into a string using a stringstream. the code snippet: unsigned char * arr; do{ fill(*arr); //if I print the array here, the print operation works fine stringstream…
raff5184
  • 344
  • 1
  • 2
  • 15
3
votes
2 answers

What is the difference between char and unsigned char?

(Edited change C/C++ to C) Please help me to find out a clean clarification on char and unsigned char in C. Specially when we transfer data between embedded devices and general PCs (The difference between buffer of unsigned char and plain char).
Dig The Code
  • 658
  • 2
  • 15
  • 32
3
votes
1 answer

#define as unsigned char

I would like to know how can I tell to compiler that a #define is an unsigned char. #define SET_BITS_LOW 0x80 Here SET_BITS_LOW is, by default, an int but I want an unsigned char
VivienG
  • 2,143
  • 3
  • 24
  • 43
3
votes
1 answer

C printf unsigned char array

I have an unsigned char array unsigned char* name = malloc(nameLength); - how can I print it with printf? %sdoes not seem to work correctly, neither does %u (seeing random icons). Here's how I create the data I want to print: __int32…
Christian Stewart
  • 15,217
  • 20
  • 82
  • 139
3
votes
1 answer

reading/writing unsigned char array from/to file using filestream

It may look simple but I'm to find the reason why it's not working. I have two functions read_file_cpp() & write_file_cpp(). read_file_cpp() reads a file and stores it in unsigned char pointer & write_file_cpp() write back data from unsigned char…
annunarcist
  • 1,637
  • 3
  • 20
  • 42
3
votes
2 answers

storing float value to unsigned char array

Sorry to ask this but I have searched for this small thing and found somthing related on this below link but was unable get any idea How to store floats in array to be used later? storing in unsigned char array How to store a float value suppose…
user1016528
  • 81
  • 1
  • 3
  • 8
3
votes
3 answers

Unsigned char to char* and int in C?

Working on some encryption that requires unsigned char's in the functions, but want to convert to a char for use after it's been decrypted. So, I have: unsigned char plaintext[16]; char *plainchar; int plainint; ... Code now populates plaintext…
Fmstrat
  • 1,492
  • 2
  • 17
  • 24
3
votes
1 answer

Why does printing an unsigned char sometimes work and sometimes not? In C

For a school project, I'm writing a blowfish encryption (just the encryption, not the decryption). I've finished the encryption itself, and I decided I would do the decryption for fun (it's easy enough in Blowfish). I used unsigned chars to…
TPXL
  • 327
  • 1
  • 3
  • 12
2
votes
1 answer

Convert UIImage data into const unsigned char myArry[100]

In objective c, I need to convert a UIImage into something that matches the following type: const unsigned char myImg[6300] = {…
Alfie Hanssen
  • 16,964
  • 12
  • 68
  • 74
2
votes
7 answers

Best way to create a string buffer for binary data

When I try the following, I get an error: unsigned char * data = "00000000"; //error: cannot convert const char to unsigned char Is there a special way to do this which I'm missing? Update For the sake of brevity, I'll explain what I'm trying to…
zeboidlund
  • 9,731
  • 31
  • 118
  • 180
2
votes
1 answer

How to use C language in Xcode to deal with network packet

I just obtained a WIFI camera. I need to develop a iPad application to send a url request to this camera and then play the mpeg4 streaming in the iPad. After receiving the request, this camera send back network packets to iPad. At the beginning of…
Fan Wu
  • 237
  • 1
  • 4
  • 11
2
votes
3 answers

Printf performing implicit casting

In the below code snippet, why do we get an output of 600? Two questions will help me understand the behavior. I specified the type for variable b to be uint8_t, why doesn't the math operation restrict to the same type? I thought PRIu8 is the right…
niil87
  • 47
  • 5
2
votes
2 answers

shifting an unsigned char by more than 8 bits

I'm a bit troubled by this code: typedef struct _slink{ struct _slink* next; char type; void* data; } assuming what this describes is a link in a file, where data is 4bytes long representing either an address or an integer(depending on…
giorgioh
  • 377
  • 1
  • 13
2
votes
2 answers

What type of cast is suitable to convert from unsigned char* to char*?

When I write data to and from a buffer to save to a file I tend to use std::vector, and I treat those unsigned chars just as bytes to write anything into, so: int sizeoffile = 16; std::vector
Zebrafish
  • 11,682
  • 3
  • 43
  • 119
2
votes
2 answers

convert uint8_t array to string

I the project I have a struct that has one member of type unsigned int array(uint8_t) like below typedef uint8_t U8; typedef struct { /* other members */ U8 Data[8]; } Frame; a pointer to a variable of type Frame is received that…
Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123