first commit
This commit is contained in:
24
Endian/C/endian.c
Normal file
24
Endian/C/endian.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void show_memory(const char* begin, size_t length)
|
||||
{
|
||||
size_t i = 0;
|
||||
for (; i < length; i++)
|
||||
{
|
||||
printf(" %.2x", 0xff & begin[i]); // 0xff is necessary due to type promotion
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
float f = 42654.2312f;
|
||||
int i = 7753238;
|
||||
printf("Printing float %f with size %ld\n", f, sizeof(f));
|
||||
show_memory((char*)&f, sizeof(f));
|
||||
printf("Printing int %d with size %ld\n", i, sizeof(f));
|
||||
show_memory((char*)&i, sizeof(i));
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user