1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Use of %, # and $

Discussion in 'C' started by arunbharathi, Jun 19, 2012.

  1. arunbharathi

    arunbharathi New Member

    Joined:
    Jun 19, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    what is the use of %, $ , # in C language.

    we know that %d is for int %s 4 string. why is the % specially used. why not # $ etc.

    any explanation for this…..
     
  2. sirama

    sirama New Member

    Joined:
    Jun 18, 2012
    Messages:
    7
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Systems Er.
    Home Page:
    Those are all called format specifiers. Suppose you want to print formatted output you will use those you listed. For example we use % to specify integer, string or float formats. You can also specify number with % stating how you want to print.

    Similarly # are mostly used for date format also used as place-holders. Check for specifier in the internet, you will get more useful information than what I am telling here...
     
    arunbharathi likes this.
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Strange question; that's the syntax, you just have to get on with it.

    But there's nothing magic about a %. It could equally well have been # or $ or anything else. K&R just picked %.
     
    arunbharathi likes this.

Share This Page