LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-24-2013, 12:35 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Why doesn't the printf format string "%0x" pad with zeroes on the left?


Hi:

I get the same output as with "%x".
 
Old 08-24-2013, 01:10 PM   #2
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
This is because you did not specify precision:
Code:
$ printf "%06x\n" 0x1a
00001a
I use program printf (1) here, but it should behave similar to printf (3).
 
2 members found this post helpful.
Old 08-24-2013, 05:09 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thanks firstfire.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script: I have string "abc____def____ghi", how to make "abc def ghi" vouser Programming 8 03-09-2010 10:01 PM
Perl - Can't use string ("html") as an ARRAY ref while "strict refs" OldGaf Programming 9 08-11-2009 11:14 AM
Minus sign in printf format string doesn't work. zebela Linux - Newbie 4 06-13-2008 01:32 AM
"Permission denied" and "recursive directory loop" when searching for string in files mack1e Linux - Newbie 5 06-12-2008 07:38 AM
Switching "nv" to "nvidia" = screen shifted to the left? mpriddy Linux - General 5 02-28-2007 10:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration