I am initializing a symlink in an ext2
inode (school assignment).
I got the idea to do it in hex
since the field is defined as uint32_t i_block[EXT2_N_BLOCKS]
.
As an example:
#include <stdio.h>
int main () {
// unsigned int is 32 bytes on my system
unsigned int i = 0x68656c6c; // hell
printf("%.*s\n", 4, &i");
I got the output
lleh
Is this because my system is little-endian? Does that mean if I hardcode the opposite order, it would not port to big-endian systems (my eventual goal is hello-world
)?
What is the best, most simple way to store a character string into an array of unsigned integers?