You are here:

C/confusion stuff

Advertisement


Question
i would like to know how the function printf() is implemented in c insense i want u to focus on the result that we would get if conversion specifiers r misused.
eg:
float a=89.9;
printf("%i",a);
gives 0 as out put
but how ....
 pliz explain using implementation in run time stack


Answer
> Looks like, you have copied and pasted your assignment question here!
> You will need to know the low-level system calls to program printf().
>
> -Narendra

Looks like you wanted source code for this or wanted me to do your assignment.
If you really serious about learning programming, then you must do it and then only you will learn.

But, today the software is going towards reuse and most of the major OS have opened their source code.
You can see the source code of Linux and Solaris in the internet.
If you had done a search in the web, you could have found it.

Here is the link, where you can see the source code of printf.c of Solaris:
http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/prin...
http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/csh/printf.c
http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libbc/libc/std...

But, note that it is not a simple code and you will need to know many more things that I had mentioned before to understand the code.

I understood that, you were unhappy with my answer, by looking at the ratings that you have given.
I don't care for your ratings. I am not here to gain better ratings. Nobody honours you for the ratings taken! I am answering this on my own and I want the questioner to be happy with the answer.
Since you were unhappy, I am writing all this.

Note that, I am working as an engineer in a reputed MNC, which is known for its Unix OS.

The way you have given ratings, just reflects your mindset.
If you were seeing a solution, then you could have asked for more clarifications.
That is the mindset of a person who wants to learn.
You can chose your path.

-Narendra

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.