473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

definition of stdio.h

lak
if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?

Oct 8 '07 #1
17 8904
lak wrote:
if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
Either in <stdio.hor a header included by <stdio.h>

--
Ian Collins.
Oct 8 '07 #2
Ian Collins said:
lak wrote:
>if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
Either in <stdio.hor a header included by <stdio.h>
Deeply unlikely. Only an idiot would define printf and scanf in a header.
Since you yourself are not an idiot, I think you must have misread his
requirement. He is after the function definitions, not the declarations.

--
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
Oct 8 '07 #3
Richard Heathfield wrote:
Ian Collins said:
>lak wrote:
>>if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
Either in <stdio.hor a header included by <stdio.h>

Deeply unlikely. Only an idiot would define printf and scanf in a header.
Since you yourself are not an idiot, I think you must have misread his
requirement. He is after the function definitions, not the declarations.
:)

A bit odd that the OP's <stdio.honly has symbolic constants.

--
Ian Collins.
Oct 8 '07 #4
lak wrote:
if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
It should be in <stdio.h>. However it might use so many compiler
extensions as to unrecognisable to a beginner or someone who only knows
ISO C. Also as Ian notes, it might be in another file included by
<stdio.h>.

Write a simple program using both printf and scanf and direct the
compiler to produce preprocessed output. If you examine this output
you'll find the declarations for printf and scanf somewhere.

Oct 8 '07 #5
In article <11**********************@o80g2000hse.googlegroups .com>,
lak <la********@gmail.comwrote:
>if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
You want to look at the source code for the library, which may well
not be available on you system. If you're using Linux, BSD, or some
other free operating system you will be able to get hold of it,
otherwise you're probably out of luck.

You can find the FreeBSD implementation at

http://www.freebsd.org/cgi/cvsweb.cg...ib/libc/stdio/

(click on the red version numbers to see the code).

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Oct 8 '07 #6
Richard Heathfield wrote:
Ian Collins said:
>lak wrote:
>>if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
Either in <stdio.hor a header included by <stdio.h>

Deeply unlikely. Only an idiot would define printf and scanf in a
header. Since you yourself are not an idiot, I think you must have
misread his requirement. He is after the function definitions, not the
declarations.
Oops. I made the same mistake! Oh well.

Oct 8 '07 #7
In article <fe**********@aioe.org>, santosh <sa*********@gmail.comwrote:
>if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
>If you examine this output
you'll find the declarations for printf and scanf somewhere.
I suspect he really wants the definitions, not the declarations.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Oct 8 '07 #8
Richard Heathfield <rj*@see.sig.invalidwrites:
Ian Collins said:
>lak wrote:
>>if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
Either in <stdio.hor a header included by <stdio.h>

Deeply unlikely. Only an idiot would define printf and scanf in a header.
printf and scanf could be defined as macros. (I *think* that C99's
variadic macros are up to the task.)
Since you yourself are not an idiot, I think you must have misread his
requirement. He is after the function definitions, not the declarations.
He asked for definitions, but I'm not convinced that that's really
what he's after (which is why I asked him for clarification
elsethread).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 8 '07 #9
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote:
>whereas the definition is something like this:

int printf(const char * restrict format, ...)
{
/* lots and lots of code here */
}
Probably not "lots and lots", in this case. I suspect that most
implementations will look just like this one from FreeBSD:

int printf(char const * restrict fmt, ...)
{
int ret;
va_list ap;

va_start(ap, fmt);
ret = vfprintf(stdout, fmt, ap);
va_end(ap);
return (ret);
}

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Oct 8 '07 #10
On Mon, 08 Oct 2007 02:43:16 -0700, Keith Thompson wrote:
Richard Heathfield <rj*@see.sig.invalidwrites:
>Ian Collins said:
>>lak wrote:
if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?

Either in <stdio.hor a header included by <stdio.h>

Deeply unlikely. Only an idiot would define printf and scanf in a header.

printf and scanf could be defined as macros. (I *think* that C99's
variadic macros are up to the task.)
There must be also a real declaration, in case I use
(printf)("foo");
or
#undef printf
printf("foo");
And that one is very unlikely to be also a definition. There still
have to be a (probably precompiled) printf function somewhere.
--
Army1987 (Replace "NOSPAM" with "email")
A hamburger is better than nothing.
Nothing is better than eternal happiness.
Therefore, a hamburger is better than eternal happiness.

Oct 8 '07 #11
Army1987 <ar******@NOSPAM.itwrites:
On Mon, 08 Oct 2007 02:43:16 -0700, Keith Thompson wrote:
>Richard Heathfield <rj*@see.sig.invalidwrites:
>>Ian Collins said:
lak wrote:
if i view stdio.h there are only symbolic constants.
where is the definition of printf and scanf is available?
i want to see the definition of printf and scanf and where it is
stored?
>
Either in <stdio.hor a header included by <stdio.h>

Deeply unlikely. Only an idiot would define printf and scanf in a header.

printf and scanf could be defined as macros. (I *think* that C99's
variadic macros are up to the task.)

There must be also a real declaration, in case I use
(printf)("foo");
or
#undef printf
printf("foo");
And that one is very unlikely to be also a definition. There still
have to be a (probably precompiled) printf function somewhere.
Sure. My (somewhat silly) point was simply that a non-idiot might
define printf and scanf in a header (though it must also be fully
defined elsewhwere).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 8 '07 #12
Keith Thompson said:
>>Richard Heathfield <rj*@see.sig.invalidwrites:

[...] Only an idiot would define printf and scanf in a
header.

[...] My (somewhat silly) point was simply that a non-idiot might
define printf and scanf in a header (though it must also be fully
defined elsewhwere).
Yes, you have made your point well. I must re-phrase my claim to take your
objection into account.

Only an idiot or a completely macro-crazed bozo would define printf and
scanf in a header.

:-)

--
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
Oct 8 '07 #13
Richard Heathfield <rj*@see.sig.invalidwrites:
Keith Thompson said:
>>>Richard Heathfield <rj*@see.sig.invalidwrites:
>
[...] Only an idiot would define printf and scanf in a
header.

[...] My (somewhat silly) point was simply that a non-idiot might
define printf and scanf in a header (though it must also be fully
defined elsewhwere).

Yes, you have made your point well. I must re-phrase my claim to take your
objection into account.

Only an idiot or a completely macro-crazed bozo would define printf and
scanf in a header.

:-)
printf() is simply fprintf() with the first argument implicitly set to
stdin. Likewise, scanf() is simply fscanf() with the first argument
implicitly set to stdout.

Assuming a C99-compliant compiler, and assuming that C99's variadic
macros are up to the task (I suppose I should confirm that at some
point), I see no reason not to define printf(...) as a macro that
invokes fprintf(stdout, ...) (in addition, of course, to the mandatory
definitions (outside the header) as functions).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 8 '07 #14
Keith Thompson said:

<snip>
Assuming a C99-compliant compiler, and assuming that C99's variadic
macros are up to the task (I suppose I should confirm that at some
point), I see no reason not to define printf(...) as a macro that
invokes fprintf(stdout, ...) (in addition, of course, to the mandatory
definitions (outside the header) as functions).
Ah, a very straight bat indeed. Well played, sir. :-)

--
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
Oct 8 '07 #15
Keith Thompson wrote:
>
.... snip ...
>
printf() is simply fprintf() with the first argument implicitly
set to stdin. Likewise, scanf() is simply fscanf() with the first
argument implicitly set to stdout.
I suspect you have performed some unusual operations on the i/o
system before using these macros. :-)

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 9 '07 #16
CBFalconer <cb********@yahoo.comwrites:
Keith Thompson wrote:
... snip ...
>>
printf() is simply fprintf() with the first argument implicitly
set to stdin. Likewise, scanf() is simply fscanf() with the first
argument implicitly set to stdout.

I suspect you have performed some unusual operations on the i/o
system before using these macros. :-)
Only in my head. (Swap stdin and stdout, of course.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 9 '07 #17
On Mon, 08 Oct 2007 15:04:13 -0700, Keith Thompson wrote:
Richard Heathfield <rj*@see.sig.invalidwrites:
>Only an idiot or a completely macro-crazed bozo would define printf and
scanf in a header.

Assuming a C99-compliant compiler, and assuming that C99's variadic
macros are up to the task (I suppose I should confirm that at some
point), I see no reason not to define printf(...) as a macro that
invokes fprintf(stdout, ...) (in addition, of course, to the mandatory
definitions (outside the header) as functions).
Considering that it is very likely that the only differences
between the (real) definitions of printf and fprintf are
+ int printf(const char * restrict format, ...)
- int fprintf(FILE * restrict stream, const char * restrict format, ...)
and
+ ret = vfprintf(stdout, format, ap)
- ret = vfprintf(stream, format, ap)
I can't see any advantage in using the macro...
--
Army1987 (Replace "NOSPAM" with "email")
A hamburger is better than nothing.
Nothing is better than eternal happiness.
Therefore, a hamburger is better than eternal happiness.

Oct 21 '07 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AMT2K5 | last post by:
Hello. When I compile my program I recieve lots and lots of the following message which I am trying to decipher. "xxx was declared deprecated". What exactly does that mean?
7
by: A_StClaire_ | last post by:
hi, I'm working on a project spanning five .cpp files. each file was used to define a class. the first has my Main and an #include for each of the other files. problem is my third file...
2
by: alan | last post by:
Hi all, I have create a simple function and make a pure C dll. When I use this DLL from my main program, I found I cannot see this function's definition tips (yellow box). It works fine, but no...
3
by: Robert Mens | last post by:
Hi, My compiler/linker gives me the strangest error: process.o(.text+0x0): In function `login_user_login': : multiple definition of `login_user_login' login.o(.text+0x0): first defined here...
2
by: leo.hou | last post by:
Hi experts, I am new to linux and all the type definitions are driving me mad. What is the best way to check a type definition in linux? When I use man page to check some function definition, I...
18
by: shaanxxx | last post by:
I have following code . #include<stdio.h> int i; int i; int i; int main() { printf("%d",i); return 0;
7
by: Kristian Virkus | last post by:
Hello! I would like to write a C programm with multiple include files, where one may use another one (to print the value of a variable). When I try to compile the program below, the linker...
3
by: Atropo | last post by:
Hi, all. As you can see I'm just begining on C. with the tutorial "Sams Teach Yourself C in 24 Hours" as a starter. on aix 5.2 when compiling a helloWorld the gcc throws some warnings the...
7
by: sh.vipin | last post by:
/* Sample code*/ #include <stdio.h> int a; //line # 3 int a; //line # 4 int main (int argc, char *argv){ printf("a is %d",a); }
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.