Guys, I want to know if float variables can be used in sprintf() function.
Like, if we write:
sprintf(str,\"adc_read = %d \
Yes, and no. Despite what some other replies have said, the C compiler is required to perform conversions for sprintf(), and all other variadic functions, as follows:
char => intshort => intfloat => double(and signed/unsigned variants of the above integral types)
It does this precisely because sprintf() (and the other print()-family functions) would be unusable without it. (Of course, they're pretty unusable as it is.)
But you cannot assume any other conversions, and your code will have undefined behaviour - read: crash! - if you do it.