Forum Discussion
Altera_Forum
Honored Contributor
15 years agoprintf("%.4s", &integer_a) will print at most 4 characters, but you really need to print the characters separately (unless you know that int is 32bits (or rather 4 times the size of char), that you have 4 characters, and that they are in the right bytes of the int.
The NiosII is 'little endian' (the lowest address of a word is it least significant byte) so that x=0x414243; printf("<%.4s>", &x) will generate "<CBA>". On a 'big endian' system (eg sparc or ppc) the same code will generate "<>". Setting x=0x41424344 would give "<DCBA>" and "<ABCD>" respectively.