One more thing, I was trying to buffer it with a structure. But somehow, its not working. Just curious to know what is the problem. See if you can figure it out?
Have you checked the size of int, long long and buffer_t? You'll probably find that buffer_t is larger than the sum of it's parts. You need to pack the structure to byte alignment.