C

S

sangeeta chowdhary

Hey guys,
I want read some standard book for C.I want to know how printf and
scanf are implemented?
How and when memory is allocated.What exactly happens at compile time?
How stack is used and how stack is used in c programming?

Can you please suggest me any book which can answer my all questions?
Thanks a lot in advance.
 
T

Tom St Denis

Hey guys,
I want read some standard book for C.I want to know how printf and
scanf are implemented?
How and when memory is allocated.What exactly happens at compile time?
How stack is used and how stack is used in c programming?

Those are all different [and not necessarily C related] questions...

For C: K&R 2nd edition is a good start.

How scanf/printf are implemented: read up a good manpage on vsprintf
[for instance]

The rest are fairly generic comp.sci questions. Google around.

Tom
 
K

Keith Thompson

sangeeta chowdhary said:
I want read some standard book for C.I want to know how printf and
scanf are implemented?
How and when memory is allocated.What exactly happens at compile time?
How stack is used and how stack is used in c programming?

Can you please suggest me any book which can answer my all questions?
Thanks a lot in advance.

There is no single answer to any of your questions. The C language
itself specifies how programs behave; the underlying implementation
can and will differ from one compiler and operating system to
another.

A lot of what you're asking about isn't at all specific to C.
For a given system, it's likely to be similar if not identical for
any compiled language.

Some compilers are open-source (gcc, for example), so you can look
at the compiler implementation yourself if you like. It's a huge
chunk of code, not for the faint of heart. You might also want to
learn about compiler theory; Google "Dragon Book".

The same applies to run-time libraries and operating systems.

P.J. Plauger has published a book, "The Standard C Library", which
presents one possible implementation of the standard C library
(C90, not C99). Again, there is no one implementation; this is
just an example.

I doubt that any one book can answer all your questions.
 
U

Uno

Keith said:
There is no single answer to any of your questions. The C language
itself specifies how programs behave; the underlying implementation
can and will differ from one compiler and operating system to
another.

A lot of what you're asking about isn't at all specific to C.
For a given system, it's likely to be similar if not identical for
any compiled language.

Some compilers are open-source (gcc, for example), so you can look
at the compiler implementation yourself if you like. It's a huge
chunk of code, not for the faint of heart. You might also want to
learn about compiler theory; Google "Dragon Book".
http://en.wikipedia.org/wiki/Dragon_Book_(computer_science)

Hmm.

The same applies to run-time libraries and operating systems.

P.J. Plauger has published a book, "The Standard C Library", which
presents one possible implementation of the standard C library
(C90, not C99). Again, there is no one implementation; this is
just an example.

These implementations aren't created equally. Plauger's is
especially-useful. I think gcc is different, but I don't have much
evidence for it.
I doubt that any one book can answer all your questions.

Maybe he completely lacks true curiosity, in which case, any holy text
would suffice.
 
A

Adi

Hey guys,
I want read some standard book for C.I want to know how printf and
scanf are implemented?
How and when memory is allocated.What exactly happens at compile time?
How stack is used and how stack is used in c programming?

Can you please suggest me any book which can answer my all questions?
Thanks a lot in advance.

Ever heard of google...?
 
J

Jorgen Grahn

Ever heard of google...?

People can answer questions like that ("which book?") better than
Google. And a good book is also better than Google for the specific
low-level stuff he seems interested in.

Unfortunately I know of no good book. I have learned those things over
the years by talking to people and by experimentation. One on compiler
construction, perhaps, like the "Dragon" book? And one on assembly
programming?

I do believe it's good to have a mental model of how C maps to the
machine, even if it's just one possible implementation.

/Jorgen
 
D

Dann Corbit

People can answer questions like that ("which book?") better than
Google. And a good book is also better than Google for the specific
low-level stuff he seems interested in.

Unfortunately I know of no good book. I have learned those things over
the years by talking to people and by experimentation. One on compiler
construction, perhaps, like the "Dragon" book? And one on assembly
programming?

I do believe it's good to have a mental model of how C maps to the
machine, even if it's just one possible implementation.

A possible solution would be to read a standard C book like "The C
Programming Language":
http://en.wikipedia.org/wiki/The_C_Programming_Language_(book)
And then study the code for the GCC compiler. The questions are
muddled. For example:
"How stack is used and how stack is used in c programming?"
Shows that the O.P. needs to understand fundamentals first.

IMO-YMMV
 
J

Jorgen Grahn

A possible solution would be to read a standard C book like "The C
Programming Language":
http://en.wikipedia.org/wiki/The_C_Programming_Language_(book)

I have to admit I haven't read it, but does it talk about these
issues?
And then study the code for the GCC compiler.

Haven't tried, but I think you'd get lost quickly. The "normal" mental
model would be just one special case among tons of optimizations. And
there's an intermediate abstract machine level in there too.

Another idea: write some code, compile it to assembly, at different
optimization levels, and read it. But you'd need to know one assembly
language.
The questions are
muddled. For example:
"How stack is used and how stack is used in c programming?"
Shows that the O.P. needs to understand fundamentals first.

And/or that he's not very good with english.

/Jorgen
 
J

Jorgen Grahn

For general compiler design and implementation, I liked
"Compilers - Principles, Techniques and Tools"
by Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman

Nicknamed "the dragon book" -- I've already mentioned it under that
name, I think.

/Jorgen
 

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

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top