By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

a doubt in sprintf

P: 25
Hello friends,

I cannot undestand the difference between the following two commands. Infact I want to know exactly what does the number between % and X does in this command.

And what is the significance of 0 before the number, after %.

sprintf( m_szCommand, "TX %01X", 0x0801 );

sprintf( m_szCommand, "TX %04X", 0x0801 );

Assume that I have declared m_szCommand as char m_szCommand[10]

Can any one of you explain this?

thanks in advance
RSR
Mar 20 '07 #1
Share this Question
Share on Google+
3 Replies


RedSon
Expert 5K+
P: 5,000
Read this:

http://en.wikipedia.org/wiki/Printf

Especially the part about format placeholders.
Mar 20 '07 #2

Expert 100+
P: 1,510
why don't you write a small program containing these statements and see what they do? Then try changing various things.
Mar 20 '07 #3

P: 25
rsr
why don't you write a small program containing these statements and see what they do? Then try changing various things.
thanks guys..i got it..infact i had written a small program and tried chaging things before but the results were pretty confusing..anyways now its clear
Mar 20 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.