I'm reading an image file and I want to show the format it was compressed in console.
In example, I read this: format = 861165636 (0x33545844), as my CPU reads and writes in Little Endian I do format = __builtin_bswap32(format); so now format = 1146639411 (0x44585433), and 0x44585433 = "DXT3" in ASCII.
I want to print this ("DXT3") but not using and extra variable, I mean, something like this printf("Format: %s\n", format); (that obviously crash). There's a way to do it?
orderparatameter indicates if you want to start from the most significant byte or not.https://godbolt.org/z/WWE9Yr
Another option
https://godbolt.org/z/eEj755