printf function changes int to char when using format specifier?

V

vlsidesign

Example
printf("I have %d cars. \n", 10);

Is it more correct to say that the printf function doesn't insert the
integer, rather into changes the integer into chars and then inserts
it?
 
K

Keith Thompson

vlsidesign said:
Example
printf("I have %d cars. \n", 10);

Is it more correct to say that the printf function doesn't insert the
integer, rather into changes the integer into chars and then inserts
it?

printf inserts (into the stdout output stream) a textual representation of the
int value 10.

It doesn't change the integer into anything; 10 is still an integer. Rather, it
computes a sequence of characters {'1', '0'} from the integer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top