how do i escape "%" in printf?

i tried to do %d in a printf() statement, but the % is not escaped.

Comments

  • : i tried to do %d in a printf() statement, but the % is not escaped.
    :
    When you write the character in a string or character constant, the following character is taken as a code for an escape sequence. According to Kernighan & Ritchie's book, valid escape sequences are:
    a (BELL)
     (BS)
    f (FF)

    (LF)

    (CR)
    (HT)
    v (VT)
    \ ()
    ? (?)
    ' (')
    " (")
    ooo (octal number ooo representing an ASCII code)
    xhh (hexadecimal number hh representing an ASCII code)

    If the character after the is not of those specified, the behavior is undefined.

    Is this explanation what you wanted?

    Take care, Steph.
  • : : i tried to do %d in a printf() statement, but the % is not escaped.
    : :
    : When you write the character in a string or character constant, the following character is taken as a code for an escape sequence. According to Kernighan & Ritchie's book, valid escape sequences are:
    : a (BELL)
    :  (BS)
    : f (FF)
    :
    (LF)
    :
    (CR)
    : (HT)
    : v (VT)
    : \ ()
    : ? (?)
    : ' (')
    : " (")
    : ooo (octal number ooo representing an ASCII code)
    : xhh (hexadecimal number hh representing an ASCII code)
    :
    : If the character after the is not of those specified, the behavior is undefined.
    :
    : Is this explanation what you wanted?
    :
    : Take care, Steph.
    :
    Actually, I wanted to display "%d" in a printf statement. It's not of much importance that I do it, but if it's possible, I would like to do it.
  • : : : i tried to do %d in a printf() statement, but the % is not escaped.
    : : :
    : : When you write the character in a string or character constant, the following character is taken as a code for an escape sequence. According to Kernighan & Ritchie's book, valid escape sequences are:
    : : a (BELL)
    : :  (BS)
    : : f (FF)
    : :
    (LF)
    : :
    (CR)
    : : (HT)
    : : v (VT)
    : : \ ()
    : : ? (?)
    : : ' (')
    : : " (")
    : : ooo (octal number ooo representing an ASCII code)
    : : xhh (hexadecimal number hh representing an ASCII code)
    : :
    : : If the character after the is not of those specified, the behavior is undefined.
    : :
    : : Is this explanation what you wanted?
    : :
    : : Take care, Steph.
    : :
    : Actually, I wanted to display "%d" in a printf statement. It's not of much importance that I do it, but if it's possible, I would like to do it.
    :
    Ok, so write:
    [code]printf("%%d...[/code]

    Take care, Steph
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories