I have been working on this for hours, but I cannot figure out what I am doing wrong. I am trying to convert a 64-bit integer to a character array and write it to a file. Here is the code I've been playing around with:
I get these warnings, but it confuses me since I am working with 64-bit:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
main2.cpp: In function 'int main()':
main2.cpp:21:17: warning: left shift count >= width of type [enabled by default]
(buffer[4] << 32) | (buffer[5] << 40) |
^
main2.cpp:21:37: warning: left shift count >= width of type [enabled by default]
(buffer[4] << 32) | (buffer[5] << 40) |
^
main2.cpp:22:17: warning: left shift count >= width of type [enabled by default]
(buffer[6] << 48) | (buffer[7] << 56)
^
main2.cpp:22:37: warning: left shift count >= width of type [enabled by default]
(buffer[6] << 48) | (buffer[7] << 56)
^
It outputs this:
1 2
-1 -1 -1 -1 -1 -1 -1 127
18446744073709551615
I am expecting this number: 9223372036854775807
I think I am doing something stupid, but I've been programming this for a lot of hours. Does anyone have any ideas?
Thanks,
MaxterTheTurtle
[Edit:] I am on a little endian machine with the mingw32-w64 compiler.