What is %a %f etc in variables. | SoloLearn: Learn to code for FREE!

0

What is %a %f etc in variables.

I don't get why these are necessary in variables

11/21/2020 10:10:30 AM

Alex Mih

7 Answers

New Answer

+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.

+3

Refer to http://www.cplusplus.com/reference/cstdio/printf/ for an explanation of format specifiers used with printf(). Format specifiers are also used with other input and output functions such as: fprintf, sprintf, scanf, fscanf, and sscanf.

+2

They are format specifier. When you need to put variables into the string. You need to use them.

+1

Thank you

+1

CarrieForle %a and %A does exist, but I forgot when it's added.

+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.

0

Thank you. But what formats do they specify