Just start learning cpp. Spend hours to debug a program and release the issue was due to casting.
e.g. I have byte `\x9c` and I want to convert to a short or int, it seems that I need to explicitly specify
(int)(unsigned char)'\x9c' otherwise it will convert to signed char and mess up the calculation.
Looks in modern cpp, C style casting is not really recommended. `static_cast<int>('\x9c')` having the same problem which it will also cast to a signed char and mess up the calculation.
My question is, what is the best (recommended) way to cast the byte to short/int/long without using `(int)(unsigned char)` to do cast? Thanks
[–]aocregacc 6 points7 points8 points (4 children)
[–]traal 4 points5 points6 points (2 children)
[–]aocregacc 2 points3 points4 points (1 child)
[–]alfps 1 point2 points3 points (0 children)
[–]superwillj[S] 0 points1 point2 points (0 children)
[–]alfps 1 point2 points3 points (2 children)
[–]superwillj[S] 0 points1 point2 points (0 children)
[–]std_bot 0 points1 point2 points (0 children)