0

What is %a %f etc in variables.

I don't get why these are necessary in variables

21st Nov 2020, 10:10 AM
Alex Mih
Alex Mih - avatar
7 Answers
+ 1
Each format specify each type of variable. For example, %f is for float. So if you need to put a float variable into the string, use it like "My float: %f". And put the variable at another paremeter. For example, printf("My float: %f, theFloatVariable); You also need format specifier for scanf.
21st Nov 2020, 11:06 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
They are format specifier. When you need to put variables into the string. You need to use them.
21st Nov 2020, 11:02 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Thank you
21st Nov 2020, 11:07 AM
Alex Mih
Alex Mih - avatar
+ 1
CarrieForle %a and %A does exist, but I forgot when it's added.
23rd Nov 2020, 8:46 AM
LastSecond959
LastSecond959 - avatar
+ 1
LastSecond959 after some searching I found out %a actually exists. Thanks for your correction. Here is what I found: %a was added in C99. It is used to display a hexadecimal (16 based) of a float and double. And so was %A.
23rd Nov 2020, 9:32 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Thank you. But what formats do they specify
21st Nov 2020, 11:03 AM
Alex Mih
Alex Mih - avatar