Skip to content

Commit 8462611

Browse files
committed
examples/read_write: Fix hexadecimal value
Found by @kwikius in #74
1 parent 7ad6470 commit 8462611

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/read_write/read_write.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ int main(int argc, char *argv[]) {
5353
} else if ((strcmp(argv[2], "write") == 0) && (argc == 5)) {
5454
g_operation = WRITE;
5555

56-
if ((strlen(argv[4]) >= 2) && (argv[4][0] == '0') && (argv[4][0] == 'x')) {
57-
value_data = strtol(argv[4], NULL, 0);
58-
} else {
56+
if ((strlen(argv[4]) >= 2) && (argv[4][0] == '0') && ((argv[4][1] == 'x') || (argv[4][1] == 'X'))) {
5957
value_data = strtol(argv[4], NULL, 16);
58+
} else {
59+
value_data = strtol(argv[4], NULL, 0);
6060
}
6161
printf("Value to write: 0x%lx\n", value_data);
6262
} else {

0 commit comments

Comments
 (0)