Result of this code:
const char *buff = "*_2D 1"; char field[10]; int flag; sscanf(buff, "%s %d", field, &flag); printf("field:%s flag:%i\n", field, flag);
there is field:*_2D flag:1
However, changing the int value to bool will produce strange behavior:
const char *buff = "*_2D 1"; char field[10]; bool flag; sscanf(buff, "%s %d", field, &flag); printf("field:%s flag:%i\n", field, flag);
Output field: flag:1
Can anyone explain what is going on here? I would think that bool would be interpreted as an int, which apparently there is, but the rest of the line disappears.
source share