R
Richard Heathfield
Nick said:So an extern int printf(const char *, ...); is not required?
The prototype is indeed required. Perhaps Martin didn't notice that
<stdio.h> had not been included.
Nick said:So an extern int printf(const char *, ...); is not required?
Richard said:Nick Austin wrote:
The prototype is indeed required. Perhaps Martin didn't notice that
<stdio.h> had not been included.
From: Ravi (e-mail address removed)
Date: 9/22/03 6:18 AM Hawaiian Standard Time
Message-id: <[email protected]>
#define A B
#define B A
main()
{
int A=5;
float B=6.0;
printf("\n %d %f",A,B);
printf(" %d %f",B,A);
}
Take a look at this program. What is the output?
Is it implementation dependent?
main()
{
int B=5;
float A=6.0;
printf("\n %d %f",B,A);
printf(" %d %f",A,B);
}
But the macros simply mean that when the code is compiled A and B are
switched..
One more redicilous question:
#define scanf "%s is a string"
void main()
{
printf(scanf,scanf);
}
What's the output?
Assuming that printf has been declared as usual and the compiler is borken
and accepts void main() I'd expect
%s is a string is a string
And can you explain how you come to this conclusion?
Do you think it is a good question? (Of course assume it was asked
with the header included and was int main and returned etc.)
Bigdakine said:[...]Subject: Your opinion
From: Ravi (e-mail address removed)
Date: 9/22/03 6:18 AM Hawaiian Standard Time
Message-id: <[email protected]>
#define A B
#define B A
main()
{
int A=5;
float B=6.0;
printf("\n %d %f",A,B);
printf(" %d %f",B,A);
}
But the macros simply mean that when the code is compiled A and B are
switched..
So that as far the compiler is concerned the code is :
Nils said:Assuming that printf has been declared as usual and the compiler is borken
and accepts void main()
I'd expect
%s is a string is a string
Martin said:Maybe Martin had posted even earlier a list of 6 errors, fully explaned,
including this one.
Bertrand Mollinier Toublet said:I don't get it. Why would d) be expected ?
Ravi said:What's worse it had void main() originally and also a clrscr()
somewhere in between.
And the funniest part:
"What is the output on compiling the program:"
When they actually meant running the program.
LOL
And they think they are testing someones technical skill.
One more redicilous question:
#define scanf "%s is a string"
void main()
{
printf(scanf,scanf);
}
What's the output?
I think the output of this is not certain as well.
Micah Cowan said:None of the answers make any real sense, but d) seems the easiest
conclusion to arrive at if you have a *very* broken conception of how
C works. I would not expect (in the real world) any of the above, but
instead garble for some of the values, with a possible runtime
crash. Any of a through d, obviously, is possible (theoretically), and
none are more correct than the others...
Micah Cowan said:Actually, the output is very certain, provided that the prototype for
main() is fixed, and appropriate headers #included.
%s is a string is a string
Is what I would expect.
And can you explain how you come to this conclusion?
Do you think it is a good question? (Of course assume it was asked with
the header included and was int main and returned etc.)
Ben Pfaff said:No, it doesn't. Try a C preprocessor. The macros are no-ops.
Ben Pfaff said:No, it doesn't. Try a C preprocessor. The macros are no-ops.
^Martin Ambuhl said:Ask Don Pop about details on thinking before you post.
In said:I don't get it. Why would d) be expected ?
In said:Actually, the output is very certain, provided that the prototype for
main() is fixed, and appropriate headers #included.
%s is a string is a string
Is what I would expect.
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.