0

What datatype to use to store 1 byte of number data in C/C++

When I practice and do coding at home using the MinGW compiler For storing 1 byte of datum I usually use the datatype 'char' which might be signed and unsigned or whatever is needed. I have never faced any problem compiling the code on MinGW and the code executes fine in my computer. When I was asked to show my own presentation at the training center I used the same code and compiled it. Although I could execute the code Compiler gave a warning . I don't really remember the exact warning message right now, but it was something like , "warning: storing integer data in char type". That computer was using Visual C++ 6.0. But I have never had this problem in my MinGW compiler So what should I use to store 1 byte of datum that is a number ? , char or int_8t ?

29th Jun 2022, 1:47 PM
CoderBittu
CoderBittu - avatar
1 Odpowiedź
+ 3
I like int_8t better because it makes the intention clear. Unless it's a small and simple code where importing a library just to get these types would be too much.
29th Jun 2022, 2:24 PM
Emerson Prado
Emerson Prado - avatar