Just a bit of fun :)
- does it compile?Code:#include <stdio.h>
int main ( void ) {
printf,"%d",32;
return 0;
}
- does it run?
- what's the output?
Printable View
Just a bit of fun :)
- does it compile?Code:#include <stdio.h>
int main ( void ) {
printf,"%d",32;
return 0;
}
- does it run?
- what's the output?
Yes, yes, and nothing.
You should have used invisible text or something, so as not to spoil things for the rest of us . . . :)
http://www.eskimo.com/~scs/cclass/int/sx4db.html
EDIT: Ok, so I wasn't supposed to compile it, sorry. I thought maybe it was some experiment or something. I guess I could do like dwks said and color my text invisible.
I was going to mention the warnings, but you beat me to it.
It's kind of like doing this.
so you get three warnings about statements that do nothing.Code:#include <stdio.h>
int main(void) {
printf;
"%d";
32;
return 0;
}
S'ok. swoopy did exactly the same thing, after all. :)
What would make it more interesting would be if you used the return value.
I'm sure many people know that printf() returns the number of characters printed (but who ever uses that value?), so you might think that x is set to 2. But no, it's 32. :)Code:int x = printf, "%d", 32;
After your first post, I thought maybe it outputted a space, so I double checked, and it did not.
Here's some more fun:
- what is it printing?Code:#include <stdio.h>
int main(void)
{
char s[4];
return printf(s, sprintf(s, "%s", "%*p"), printf);
}
- is the same thing printed after each execution?
- what about after recompiling?
Answer (just guessing, I didn't compile it) in invisible text:
- The address of printf
- almost certainly, unless the dynamic library containing printf() was re-loaded for some reason
- probably, unless printf was linked statically
<end of text>
BTW, you made me re-write my answer several times . . . very nice program. :)
jhgjhg
I agree with dwks.
Well that's just witchcraft ;)