On 3/10/2014 3:57 PM, SAHIL MAHLA wrote: [Googlespace corrected]
On 3/10/2014 3:20 PM, SAHIL MAHLA wrote:
[...]
int main(void)
{
int i = 1;
double j=i;
incme(&j);
printf("%d,%d",i,j);
return 0;
}
[...]
That is one possible outcome. (Since the program has what
is called "undefined behavior," *all* outcomes are possible.)
[...]
What do you mean by undefined behaviour in your comment.
The C language Standard defines what a C program will do,
but only if the program "follows the rules." When the program
does something that violates the rules, the C language does not
say what will happen. Formally, the C Standard says that what
happens when the rules are broken is "undefined behavior."
Your program violates the rule that the format string for
a printf() call must match the remaining arguments. Specifically,
you have attempted to use "%d" (which requires an `int' argument)
with an argument of type `double'.
By way of analogy: You have filled your car's petrol tank
with orange juice, and the maintenance manual does not say how
much or what kind of damage that might do to the engine. After
you abuse the car, its behavior is undefined.
--
Eric Sosman
(e-mail address removed)