uint8_t (C language - Type). uint8_t stores an 8-bit unsigned number, from 0 to 255. It is equal to unsigned char.
Questions tagged [uint8t]
272 questions
3
votes
1 answer
Proper modern way of converting two uint8_t into int16_t
What's the proper modern C++ way of converting two uint8t's into one int16_t that would satisfy clang-tidy?
a[0] << 8 | a[1]
If a[0] >= 128, I want the result to wrap around, resulting in a negative value.
Clang-Tidy message is
Use of a signed…

vasily
- 2,850
- 1
- 24
- 40
3
votes
2 answers
How to interpret byte as int?
I have a byte array recived from Cpp program.
arr[0..3] // a real32,
arr[4] // a uint8,
How can I interpret arr[4] as int?
(uint)arr[4] // Err: can't implicitly convert string to int.
BitConverter.ToUint16(arr[4]) // Err: Invalid…

Ben
- 1,133
- 1
- 15
- 30
3
votes
2 answers
Converting hexadecimal to uint8_t in C++
I am working in C++ and let's say I have the following hexadecimal as a string
string key = "F3D5";
how can I convert it to an array of uint8_t?
Actually, I have an algorithm that generate a key of type uint8_t*, and I convert this key to…

Elie Daher
- 271
- 1
- 4
- 13
3
votes
2 answers
How to convert HEX string to UInt16?
I have a HEX string d285 and I want to convert it UInt16, please guide me how I can convert it. I tried this
let buffer = UInt16("\(UInt8(text, radix: 16)!)")
return Data(bytes: (buffer?.bigEndian.toBytes)!)
but it's not working

Varun Naharia
- 5,318
- 10
- 50
- 84
3
votes
1 answer
uint8 with scanf and printf in C
This code unite is a part of a bigger code of a database in C. This part takes grades of students. requirements are to use typedef unsigned char uint8 instead of a simple int.
For the life of me I can't make it work. When I use %c in scanf it skips.…

gamalanwer
- 31
- 1
- 5
3
votes
1 answer
Concatenating uint8_t to a char*
im really new to C and im having a bit of a complication creating a char* from various uint8_t
My idea is to create a char* where in each location I place a number form a matrix
For example if I have a matrix…

Jose Maria de la Torre
- 265
- 1
- 2
- 9
3
votes
2 answers
How to convert a string into an uint8_t array on Arduino?
I have a string that contains both numbers and character values like "p1200" for example. I need to convert this string into a uint8_t array, because I need to send it from my xBee.
How can I convert
String dataString = "p1200"
into
uint8_t…

Engo
- 899
- 3
- 19
- 49
3
votes
2 answers
segmentation fault with uint8_t double pointer
I have a segmentation fault when affecting a value to a[1][0], i thought my mallocs were correct but maybe there're not..
int main() {
uint8_t **a;
a = malloc(sizeof(uint8_t) * 6);
*a = malloc(sizeof(uint8_t) * 2);
a[0][0] = 1; //…

aurel_lab
- 149
- 11
3
votes
2 answers
Assignment makes integer from pointer without a cast [-Wint-conversion
I really don't understand why I have such error knowing that tmp and key are the same type and size.
uint8_t key[8] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07};
void change() {
int i;
uint8_t *tmp[8];
for(i=0; i<8; i++){
…

Addon
- 75
- 1
- 1
- 9
3
votes
1 answer
Displaying integer on an LCD
I'm trying to display an integer on an LCD-Display. The way the Lcd works is that you send an 8-Bit ASCII-Character to it and it displays the character.
The code I have so far is:
unsigned char text[17] = "ABCDEFGHIJKLMNOP";
int32_t n =…

Bobface
- 2,782
- 4
- 24
- 61
3
votes
3 answers
Converting a string to UTF 8
I've currently got a string array and I want to convert this to a UInt8 array? All of the strings are UInt8's, however I can only retrieve it as a string. Any ideas?
let stringValues = "[185, 221, 199, 111, 152, 137, 41, 137, 223, 66, 75, 132]"
I…

Jay
- 265
- 2
- 10
3
votes
3 answers
Does Indirection operator change memory representation?
Ok, I feel stupid asking this, but why does the code below output different lines?
To print the first line I take an address to the first byte of an array, interpret it as a pointer to uint16_t, take the value and print it's bits one by one.
For…

Shamdor
- 3,019
- 5
- 22
- 25
3
votes
1 answer
How to add 5 seconds to a timer
I'm trying to make a timer showing the following - hours : minutes : seconds : milliseconds. Here is my code:
var timer = NSTimer()
var startTime = NSTimeInterval()
func updateTime()
{
var currentTime = NSDate.timeIntervalSinceReferenceDate()
…

Horay
- 1,388
- 2
- 19
- 36
3
votes
4 answers
Swift: Create Array of UInt8 with defined number of Values
How is it possible to create an Array of UInt8 in Swift?
I've tried this with the following code:
var array: [UInt8] = [UInt8]()
Now I want to loop through a second UInt variable a :
for var i: Int = 0; i < a.count; i++ {
array[i] =…

user3143691
- 1,533
- 3
- 11
- 19
3
votes
3 answers
Array of uint8_t arrays
I have four uint8_t arrays:
uint8_t arrayOne[12] = { 0x00,0x01,0x00,0x00,0x00,0x06,0xFE,0x03,0x01,0xC1,0x00,0x01 };
uint8_t arrayTwo[12] = { 0x00,0x01,0x00,0x00,0x00,0x06,0xFE,0x03,0x4E,0x2D,0x00,0x0C };
uint8_t arrayThree[12] = {…

Roo
- 613
- 1
- 7
- 24