a doubt in sprintf

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsr
    New Member
    • Dec 2006
    • 25

    a doubt in sprintf

    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
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Read this:



    Especially the part about format placeholders.

    Comment

    • horace1
      Recognized Expert Top Contributor
      • Nov 2006
      • 1510

      #3
      why don't you write a small program containing these statements and see what they do? Then try changing various things.

      Comment

      • rsr
        New Member
        • Dec 2006
        • 25

        #4
        Originally posted by horace1
        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..anyw ays now its clear

        Comment

        Working...