Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > printf function changes int to char when using format specifier?

Reply
Thread Tools

printf function changes int to char when using format specifier?

 
 
vlsidesign
Guest
Posts: n/a
 
      11-14-2007
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?

 
Reply With Quote
 
 
 
 
user923005
Guest
Posts: n/a
 
      11-14-2007
On Nov 14, 1:38 pm, vlsidesign <(E-Mail Removed)> wrote:
> 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?


Neither resembles something that is correct.

man printf()
http://linux.die.net/man/3/printf

Or perhaps:
http://www.dinkumware.com/manuals/de...nt%20Functions

 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      11-14-2007
vlsidesign wrote:
> 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.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
int urldecode(char *src, char *last, char *dest) gert C Programming 20 02-16-2007 11:28 PM
problems writing a printf/scanf function that handles both int and char input from the console Dawn Minnis C Programming 6 02-08-2005 02:49 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
newbie: char* int and char *int trey C Programming 7 09-10-2003 03:24 AM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments