×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# I have question about sprintf function.

## I have question about sprintf function.

(OP)
I have question about sprintf function. such as

$mday =sprintf("%02d",$mday);

look at "d" . Sometime I see d and sometime I see "f" I want to know how difference d and f ? And expect d,f have other a,b,c,...,z ?

Thank you

### RE: I have question about sprintf function.

(OP)
Thank you very much.
hmm... Have web site example about sprintf ?

Thank again.

### RE: I have question about sprintf function.

$var = sprintf("%s %02d, %04d",$month, $day,$year);
print "Today is $var."; Should return "Today is August 24, 2000." The number before the d is the minimum field width, eg. '2' would be printed ' 2' in the$day field.  Since there is a 0 in front of the two, then the justification is filled with zeros, eg '2' would be printed '02'.

Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com

### RE: I have question about sprintf function.

hello ryojung,
here is some tips which wil be helpful for u
the various sprintf formats are :
%c - character
%s - String
%d - Signed int in decimal notation
%u - Unsigned int in decimal notation
%o - Unsigned int in octal notation (*****it is not %zero )
%x - Unsigned int in hexadecimal notation.
%e - Floating point no in scientific notation.
%f - Floating point no, in fixed decimal notation.
%g - Floating point no in %e or %f formats
%X - Same as %x but using capital letters for hex
representation.
%p - Pointer prints the memory address of a variable in

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!