Created
November 16, 2020 18:53
-
-
Save bullheadandplato/4eb890a3d04789a66c4523b650486f8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdlib.h> | |
#include<strings.h> | |
#include<stdio.h> | |
int main() { | |
char *sRaw = "02010606FFCDAB641001565"; | |
printf("All [%s]\n", sRaw); | |
char at17 = sRaw[17]; | |
printf("17 is [%c]\n", at17); | |
char at16 = sRaw[16]; | |
printf("16 is [%c]\n", at16); | |
char battery[5] = {'0', 'x', sRaw[14], sRaw[15], '\0'}; | |
printf("Battery hex is [%s]\n", battery); | |
int batteryDecimal = strtol(battery, NULL, 16); | |
printf("Battery decimal is [%d]\n", batteryDecimal); | |
return 0; | |
} |
Author
bullheadandplato
commented
Nov 16, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment