Hi,
Where can I find the source for printf ?
John 8 4956
Hi John,
Your best bet is to download libc and grab the source from there.
However, I'm willing to bet it's fairly complex and not so trivial.
-Adam Roan
"Johan" <me@knoware.nl> writes: Where can I find the source for printf ?
Whose version of printf()?
--
"I don't have C&V for that handy, but I've got Dan Pop."
--E. Gibbons
Johan wrote: Hi,
Where can I find the source for printf ?
You can find a rudimentary implementation on p156 of
K&R2. Admittedly it calls the real printf to do much of the
work, but there's enough there to give you the essence.
Or you could get a copy of the GNU library source.
Here's the source provided by Microsoft:
int __cdecl printf (
const char *format,
...
)
/*
* stdout 'PRINT', 'F'ormatted
*/
{
va_list arglist;
int buffing;
int retval;
va_start(arglist, format);
_ASSERTE(format != NULL);
_lock_str2(1, stdout);
buffing = _stbuf(stdout);
retval = _output(stdout,format,arglist);
_ftbuf(buffing, stdout);
_unlock_str2(1, stdout);
return(retval);
}
Not much help, is it?
"Johan" <me@knoware.nl> wrote: Where can I find the source for printf ?
That depends on what you need it for. If you want the source for _a_
version of printf(), at least one, probably several, are available on
the web. Of course, they're likely to be pretty much implementation-
specific, so they might be useless with your compiler. If you want the
source for _your_ version of printf(), you'll have to ask your vendor.
Richard
Somewhat related to the FAQ:
18.13: Where can I find the sources of the standard C libraries?
A: The GNU project has a complete implementation at http://www.gnu.org/software/libc/. Another source (though not
public domain) is _The Standard C Library_, by P.J. Plauger (see
the Bibliography). See also questions 18.9b, 18.15c, and 18.16.
Many C compilers come with the runtime source for their own
implementation of the standard C libraries.
"Johan" <me@knoware.nl> writes: Where can I find the source for printf ?
I wrote a simple implementation that should be reasonably
portable for Pintos, my instructional operating system. It does
not support floating-point formatting, it has a few limitations
that are probably not entirely standard compliant, and its code
is not entirely comp.lang.c compliant. Given those constraints,
you are welcome to take a look at it. It is in file
pintos/src/lib/stdio.c in the tar archive available at http://www.stanford.edu/class/cs140/.../pintos.tar.gz
--
"If I've told you once, I've told you LLONG_MAX times not to
exaggerate."
--Jack Klein
Sorry for my oxmoron. Sigh. :P
Ben Pfaff <bl*@cs.stanford.edu> writes: "Johan" <me@knoware.nl> writes:
Where can I find the source for printf ?
I wrote a simple implementation that should be reasonably portable for Pintos, my instructional operating system. It does not support floating-point formatting, it has a few limitations that are probably not entirely standard compliant, and its code is not entirely comp.lang.c compliant. Given those constraints, you are welcome to take a look at it. It is in file pintos/src/lib/stdio.c in the tar archive available at http://www.stanford.edu/class/cs140/.../pintos.tar.gz
Come to think of it, I can even provide a direct link: http://www.stanford.edu/class/cs140/...rc/lib/stdio.c
--
Ben Pfaff
email: bl*@cs.stanford.edu
web: http://benpfaff.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Grumble |
last post by:
Hello,
I have the following structure:
struct foo {
char *format; /* format string to be used with printf() */
int nparm; /* number of %d specifiers in the format string */
/* 0 <= nparm <=...
|
by: aditya |
last post by:
hi,
Can anybody please tell me that how the following printf(...)
statement works-
main(){
int d=9;
printf("%d",printf("%d"));
return 0;
|
by: teachtiro |
last post by:
Hi,
'C' says \ is the escape character to be used when characters are
to be interpreted in an uncommon sense, e.g. \t usage in printf(),
but for printing % through printf(), i have read that %%...
|
by: infobahn |
last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
|
by: whatluo |
last post by:
Hi, c.l.cs
I noticed that someone like add (void) before the printf call,
like: (void) printf("Timeout\n"); while the others does't. So
can someone tell me whether there any gains in adding...
|
by: pai |
last post by:
Hi ,
Can any one tell me how this statement of printf is behaving . how
the last digit is printed
int a=2,b=4,c=7;
printf("%d",printf("%d %d:",a,b));
//answer to this was 2 4:3
|
by: timmu |
last post by:
Someone asked me a question about integer division and printf
yesterday,
I tell him he should do a casting to float/double before you do any
interger division.
But he doesn't think so, so I try...
|
by: RedDevilDan |
last post by:
I am working on a Memory Footprint Reduction project. I came across an
idea to disable all printf statements so that less memory is required.
In addition, when there is no single printf statement,...
|
by: Old Wolf |
last post by:
Is there any possible situation for printf where %hd causes a different
result to %d, and the corresponding argument was of type 'short int' ?
|
by: linq936 |
last post by:
Hi,
I read in many places that the string to be outputted by printf()
must be ending with newline, for example, it should be
printf("Hello World.\n");
instead of
printf("Hello World.");
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |