Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove “0x” prefix #120

Closed
thewon86 opened this issue Feb 22, 2022 · 3 comments
Closed

remove “0x” prefix #120

thewon86 opened this issue Feb 22, 2022 · 3 comments
Labels
question Further information is requested

Comments

@thewon86
Copy link

int a = 0x5a5a5a5a;
printf("%x", a);

0x5a5a5a5a ?

how could i remove the prefix when using x X p format?

thx

@eyalroz
Copy link
Owner

eyalroz commented Feb 22, 2022

That's not the output you get. printf("%x",a) yields 5a5a5a5a, while printf("%#x",a) yields 0x5a5a5a5a.

@eyalroz eyalroz closed this as completed Feb 22, 2022
@eyalroz eyalroz added the question Further information is requested label Feb 22, 2022
@thewon86
Copy link
Author

That's not the output you get. printf("%x",a) yields 5a5a5a5a, while printf("%#x",a) yields 0x5a5a5a5a.

i found the code
https://github.com/eyalroz/printf/blob/3f6d9725ab50906c107028b5c75b016adad2ce81/src/printf/printf.c#L360-#L368
and

format++;

comment L360-L368, modify L1037 width = sizeof(void*) * 2U;, now solved it.

@mickjc750
Copy link

@thewon86
If you still believe printf("%x",a) yields 0x5a5a5a5a , I would suggest making an obvious change like:

printf("---> %x <---",a);

And I think you'll find that this isn't the line being executed. You most likely have a "%#x" somewhere else in your source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants