I am trying to read the memory addresses from /proc//maps and I use the following code
for (ptr = NULL; getline(&ptr, &n, file) > 0;) {
if (ptr
You're reading these values into integers; integers don't have leading zeros.
If you know how many digits you want to pad out the length to, you can specify that in your format string:
printf("r0: %08lx, r1: %08lx\n", r0, r1);
There's no way to store and recall the exact number of leading zeroes without storing the value in a different format (e.g, a string), though.
Use the 0
flag (which specifies leading zeros), followed by the padded length.
printf("r0: %08lx, r1: %08lx\n", r0, r1);
^^ ^^
This link is a good reference to look at.