hey,
i want to know the exact implementation of printf function...what i do
know is that the arguments are pushed into a stack from right to left and
the function is called and then some pointer is set up ....well, where and
how ????
also it will be helpful if u can enlightten me on how scanf works and what
should be the output of
scanf("%d %d",&a,"%f",&b,&c); a,b are ints , c is a float. 5 1955
maadhuu wrote: hey, i want to know the exact implementation of printf function...what i do know is that the arguments are pushed into a stack from right to left and the function is called and then some pointer is set up ....well, where and how ???? also it will be helpful if u can enlightten me on how scanf works and what should be the output of scanf("%d %d",&a,"%f",&b,&c); a,b are ints , c is a float.
An example howto implement a simple printf: http://www.and.org/texts/simple_printf.c.html
"maadhuu" <ma************@yahoo.com> writes: i want to know the exact implementation of printf function...what i do know is that the arguments are pushed into a stack from right to left and the function is called and then some pointer is set up ....well, where and how ????
All that is implementation-specific. Different implementations
(compilers and run-time libaries) will do things differently. As far
as the language is concerned, all you know, and all you really need to
know, is that it works.
If you want to know how one particular implementation does this, you
can generate an assembly listing, but whatever you learn from this
won't necessarily be generally applicable. (I'm not trying to
discourage you from looking into this, but implementation-specific
details are generally considered off-topic here.)
also it will be helpful if u can enlightten me on how scanf works and what should be the output of scanf("%d %d",&a,"%f",&b,&c); a,b are ints , c is a float.
Undefined behavior. The first argument to scanf() is the format
string, which controls the handling of the other arguments. You're
trying to give it a format string, a pointer to an int, *another*
format string, a pointer to an int, and a pointer to a float. Since
the expected types of the remaining arguments are determined by the
format string, not by the declaration of scanf(), a compiler might not
be able to diagnose the error; it's up to you to make sure the
arguments are correct.
You probably want something like this:
scanf("%d %d %f", &a, &b, &c);
Finally, some friendly advice. If you're going to post here, it's
best not to use abbreviations like "u" for "you". Proper
capitalization is also a good thing.
--
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.
"maadhuu" <ma************@yahoo.com> wrote i want to know the exact implementation of printf function...what i do know is that the arguments are pushed into a stack from right to left and the function is called and then some pointer is set up ....well, where and how ???? also it will be helpful if u can enlightten me on how scanf works and what should be the output of scanf("%d %d",&a,"%f",&b,&c); a,b are ints , c is a float.
C allows variadic functions (functions that take a variable number of
arguments). The facility isn't very much used, with the notable exception of
formatted IO for the printf/scanf family of functions.
If you want to write a variadic function in C, you declare the parmameter
list with a ...
eg
int maximum(int N, ...)
You then use the va_start, va_end, and va_arg macros to access the variable
list.
How does the compiler implement this? The answer varies depending on
platform, but typically arguments are passed on a stack, which also contains
the return address for the the calling function and local variables. So all
the macros do is provide memory indexes into the stack, and then extract the
data.
hey Mr Keith, thanx for this, and i shall pay heed to what u said.....i am
new to this groups, so if i offended u or something like that, sorry.
maadhuu wrote: hey Mr Keith, thanx for this, and i shall pay heed to what u said.....i am new to this groups, so if i offended u or something like that, sorry.
Then why do you continue to use the stupid (and offensive)
abbreviation 'u', fail to use an uppercase 'I', fail to quote the
relavent context from whatever you are replying to, etc.?
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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: 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: sabya123 |
last post by:
I have got a problem using printf and wprintf.
Can I use them simultaneously in a single program?
My problem is that, If I am using both of them in a program only the first one is being taken....
|
by: bryanvick |
last post by:
I just started learning C, and wrote this small program to play around
with the printf function in stdio.h. At the console, I am able to type
input at the first 2 getchar() calls, but when I call...
|
by: vlsidesign |
last post by:
If I have a "for" loop like this:
for (i = 0; i < 10; i++)
or like this
for (i = 0; i < 10; ++i)
both of the "for" loops will function the same. I also noticed if I use
a variable called j...
|
by: ericunfuk |
last post by:
printf("hello");
write(1,"hello",5);
Are these two have the same effect?Only the 2nd one work for me
sometimes?Are there situations that I can only use write() instead of
printf()?
Thanks
|
by: Googy |
last post by:
Hi friends!!
As we know that the input parameters in a function is fixed when the
function is defined but how does printf processes variable number of
input arguments ?
For example:
1....
|
by: Sanchit |
last post by:
I want to know how does printf (stdio library function) works? Does
this depand on complier (I am using gcc on Linix)
Does it uses some buffer in which it stores all what needed to be
printed...
|
by: Apoo rva |
last post by:
I am trying a code for packet capturing for only SIP traffic however I'm capturing other traffic also inspite of having setup a filter. The system I am working on is connected to a linux bridge....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
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: 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: 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...
| |