I have to read exactly 4 bytes from standard input and then to treat it like a little endian and to display it on standard output but I don't know if what I read is exactly 4 bytes. I tried this:
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <byteswap.h>
int main() {
uint32_t f;
printf("Enter a value :");
scanf ("%" SCNu32, &f);
printf("Value of integer:%d", f);
//printf("Value of integer:%d", __bswap_32(f));
return 0;
}
I'm not sure if this reads exactly on 4 bytes. I tried with the following integers:
input->output
123->123
12345678->12345678
123456789->123456789
4294967295->-1
4294967294->-2
4294967296->-1
1->1
I thought that by printing f
it will like like this: 1234000
(value of f=1234
) or 12345678
(value of f=123456789
).