'capl how to change byte format to char fomat
I want to change byte value to char value in capl. Using MD5 the input value is char and the result value is byte I want to put the result value into the input value However, the format is different and cannot be used I want to know the solution
Solution 1:[1]
If you are using arrays, you will need to define a second array of the correct type byte
of the correct length. Then use memcpy
to copy the char into the byte array.
char carr[5] = {0, -1, -2, -3, -4}; //char is signed!
byte barr[5];
memcpy (barr, carr, elCount(barr));
//data is now copied into barr, and can be used in a function that accepts byte arrays
If you are using normal scalar variables, you also can just us a normal cast:
byte b;
char c = -5;
b = (byte) c;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MaPr |