Use of %, # and $

arunbharathi's Avatar, Join Date: Jun 2012
Newbie Member
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…..
sirama's Avatar, Join Date: Jun 2012
Light Poster
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 like this
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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 like this