Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » CGoto page 1, 2, 3, 4, 5  Next

printf

 
Jump to:  
 
Jrdman
PostPosted: Tue Sep 02, 2008 11:43 pm    Post subject: printf
       
someone has an idea on how the printf function is programmed ?
 

 
Ian Collins
PostPosted: Tue Sep 02, 2008 11:43 pm    Post subject: Re: printf
       
Jrdman wrote:
Quote:
someone has an idea on how the printf function is programmed ?

One would guess those who have implemented it!

Find the source for an implementation (there are many published) and
have a look.

--
Ian Collins.
 

 
Martin Ambuhl
PostPosted: Tue Sep 02, 2008 11:43 pm    Post subject: Re: printf
       
Jrdman wrote:
Quote:
someone has an idea on how the printf function is programmed ?

Yes.
If you want to look at one method of implementation (at least for the
features in C90), check P.J. Plauger's _The Standard C Library_
(prentice Hall, 1992). An implementation of the functions declared in
<stdio.h> is all of chapter 12, pp. 225-332. I'm not sure what short
answer you expect when Plauger takes 106 pages for this.
 

 
Pilcrow
PostPosted: Wed Sep 03, 2008 2:44 am    Post subject: Re: printf
       
On Tue, 02 Sep 2008 20:42:47 -0400, Martin Ambuhl
<mambuhl@earthlink.net> wrote:

Quote:
Jrdman wrote:
someone has an idea on how the printf function is programmed ?

Yes.
If you want to look at one method of implementation (at least for the
features in C90), check P.J. Plauger's _The Standard C Library_
(prentice Hall, 1992). An implementation of the functions declared in
stdio.h> is all of chapter 12, pp. 225-332. I'm not sure what short
answer you expect when Plauger takes 106 pages for this.

Thanks for the reference.
 

 
Richard Heathfield
PostPosted: Wed Sep 03, 2008 4:15 am    Post subject: Re: printf
       
raashid bhatt said:

Quote:
On Sep 2, 7:43 pm, Jrdman <ahmed.bo...@gmail.com> wrote:
someone has an idea on how the printf function is programmed ?

unser windows itz a function call

It's a function call in *any* environment. And the rest of your answer is
unnecessarily platform-specific - the printf function can be written
portably.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 

 
raashid bhatt
PostPosted: Wed Sep 03, 2008 5:04 am    Post subject: Re: printf
       
On Sep 2, 7:43 pm, Jrdman <ahmed.bo...@gmail.com> wrote:
Quote:
someone has an idea on how the printf function is programmed ?

unser windows itz a function call in msvcrt.dll which in turn calls
kerne32.dll GetStdouthandle(); and after getting the handle it calls
WriteFile() function of kernel32.dl
 

 
Ron Ford
PostPosted: Wed Sep 03, 2008 5:10 am    Post subject: Re: printf
       
On Wed, 03 Sep 2008 06:15:59 +0000, Richard Heathfield posted:

Quote:
raashid bhatt said:

On Sep 2, 7:43 pm, Jrdman <ahmed.bo...@gmail.com> wrote:
someone has an idea on how the printf function is programmed ?

unser windows itz a function call

It's a function call in *any* environment. And the rest of your answer is
unnecessarily platform-specific - the printf function can be written
portably.

sprintf too?

Is sprintf variadic?
--
War will never cease until babies begin to come into the world with larger
cerebrums and smaller adrenal glands. 2
H. L. Mencken
 

 
Richard Heathfield
PostPosted: Wed Sep 03, 2008 5:16 am    Post subject: Re: printf
       
Ron Ford said:

Quote:
On Wed, 03 Sep 2008 06:15:59 +0000, Richard Heathfield posted:

raashid bhatt said:

On Sep 2, 7:43 pm, Jrdman <ahmed.bo...@gmail.com> wrote:
someone has an idea on how the printf function is programmed ?

unser windows itz a function call

It's a function call in *any* environment. And the rest of your answer
is unnecessarily platform-specific - the printf function can be written
portably.

sprintf too?

Yes.

Quote:
Is sprintf variadic?

Yes.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
 

 
Ron Ford
PostPosted: Wed Sep 03, 2008 5:33 am    Post subject: Re: printf
       
On Wed, 03 Sep 2008 07:16:54 +0000, Richard Heathfield posted:

Quote:
Ron Ford said:

On Wed, 03 Sep 2008 06:15:59 +0000, Richard Heathfield posted:

raashid bhatt said:

On Sep 2, 7:43 pm, Jrdman <ahmed.bo...@gmail.com> wrote:
someone has an idea on how the printf function is programmed ?

unser windows itz a function call

It's a function call in *any* environment. And the rest of your answer
is unnecessarily platform-specific - the printf function can be written
portably.

sprintf too?

Yes.

I see the syntax here in §7.2.

What I think a person might call this is an internal write. In fortran, we
go so far as to speak of "internal files," when what we really mean is the
character variable that we write to. I/O need not apply.

I'd be curious to see a useful snippet.
Quote:

Is sprintf variadic?

Yes.

This disqualifies it from fortran interop.
--
When a new source of taxation is found it never means, in practice, that
the old source is abandoned. It merely means that the politicians have two
ways of milking the taxpayer where they had one before. 8
H. L. Mencken
 

 
Malcolm McLean
PostPosted: Wed Sep 03, 2008 6:05 pm    Post subject: Re: printf
       
"Ron Ford" <ron@example.invalid> wrote in message
Quote:

[sprintf ]
I'd be curious to see a useful snippet.


sprintf() can be written portably. printf() cannot, though it can be written

on top of putchar(), which has to be platform-specific.

An example use would be in BasicDraw. Microsoft have provided a function for
setting the window title which takes, reasonably enough, a char *. Since I
want the name of the program, the version, the name of the file it is
editing, and an asterisk to represent file dirty, I can write

sprintf(buff, "BasicDraw v%g [%s]%c", version, filename, dirty ? '*' : ' ');
setwindowtitle(win, buff);

without sprintf it would be awkward to build the title, or Microsoft would
have to complicate their title-setting function to accept variable
arguments.

--
Free games and programming goodies.
LINK
 

Page 1 of 5 .:. Goto page 1, 2, 3, 4, 5  Next

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Akcent meble GIS Obszary zastosowań Portal Miasteczko slaskie pas ciążowy