Skip to content

Commit

Permalink
examples/read_write: Fix hexadecimal value
Browse files Browse the repository at this point in the history
Found by @kwikius in #74
  • Loading branch information
oliviermartin committed Mar 5, 2019
1 parent 7ad6470 commit 8462611
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/read_write/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ int main(int argc, char *argv[]) {
} else if ((strcmp(argv[2], "write") == 0) && (argc == 5)) {
g_operation = WRITE;

if ((strlen(argv[4]) >= 2) && (argv[4][0] == '0') && (argv[4][0] == 'x')) {
value_data = strtol(argv[4], NULL, 0);
} else {
if ((strlen(argv[4]) >= 2) && (argv[4][0] == '0') && ((argv[4][1] == 'x') || (argv[4][1] == 'X'))) {
value_data = strtol(argv[4], NULL, 16);
} else {
value_data = strtol(argv[4], NULL, 0);
}
printf("Value to write: 0x%lx\n", value_data);
} else {
Expand Down

0 comments on commit 8462611

Please sign in to comment.