Joe Wright
3/27/2011 6:46:00 PM
On 3/27/2011 04:02, Keith Thompson wrote:
> Joe Wright<joewwright@comcast.net> writes:
>> On 3/26/2011 21:25, bhawna wrote:
>>> #include<stdio.h>
>>> int main()
>>> {
>>>
>>> int i=99,a=3,p=44;
>>> printf("%d %d %d");
>>> return 0;
>>> }
>>>
>>> /*Output*/
>>> 134518324 99 3
>>>
>>> Is the output compiler dependent?
>> Try..
>>
>> #include<stdio.h>
>> int main(void) {
>> int i=99,a=3,p=44;
>> printf("%d %d %d", i, a, p);
>> return 0;
>> }
>> output is..
>> 99 3 44
>> ..as you might expect.
>
> bhawna, this is why it's helpful to be more explicit in your
> question, particularly about why you're asking. You asked whether
> the output is compiler dependent, but you didn't say why you thought
> it might be. You could plausibly have just forgotten to pass i,
> a, and p as arguments. You could equally plausibly have done so
> deliberately, and been curious about the consequences.
>
> Oh, and you really should have a "\n" at the end of the output;
> some systems may not show the output correctly without it.
>
> (And to nitpick even further, "int main()" should be
> "int main(void)".)
>
Hi Keith. I should have added "\n" in the format string. I did change "int
main()" to "int main(void)". You missed it. If I want authority on C here I
choose you, now that Heathfield and Pop have quit. I really miss Dan Pop.
--
Joe Wright
"If you rob Peter to pay Paul you can depend on the support of Paul."