PaulCaswell
asked on
C-Shirt design :-)
All,
Today's bit of fun!
Come up with a T-Shirt graffiti in real C code. The rules are as follows:
1. If the code produces a result, it must be humourous, the more obscure the better.
2. A C programmer, with a little thought, should discover at least a little humour in the code.
3. The more humour the better.
4. "Standard" C only please. It must compile and run on at least most, if not all implementations.
Note that the C does not need to be particularly good. Some exceptionally bad code could fit the bill.
Paul
Today's bit of fun!
Come up with a T-Shirt graffiti in real C code. The rules are as follows:
1. If the code produces a result, it must be humourous, the more obscure the better.
2. A C programmer, with a little thought, should discover at least a little humour in the code.
3. The more humour the better.
4. "Standard" C only please. It must compile and run on at least most, if not all implementations.
Note that the C does not need to be particularly good. Some exceptionally bad code could fit the bill.
Paul
Nice idea Paul :) Wonder what inspired you hehe
I've always enjoyed this site :
http://www.ioccc.org/main.html
I especially like this (quite famous) one :
int i;main(){for(;i["]<i;++i){ --i;}"];re ad('-'-'-' ,i+++"hell \
o, world!\n",'/'/'/'));}read( j,i,p){wri te(j/p+p,i ---j,i/i); }
(an entry of the first contest in 1984, by an anonymous person :))
I'll try to come up with something of myself now heh
I've always enjoyed this site :
http://www.ioccc.org/main.html
I especially like this (quite famous) one :
int i;main(){for(;i["]<i;++i){
o, world!\n",'/'/'/'));}read(
(an entry of the first contest in 1984, by an anonymous person :))
I'll try to come up with something of myself now heh
Something I came across a while ago, and has been used as a "C test" ... try to understand what it does without compiling :) :
#include <stdio.h>
char *c[] = { "ENTER", "NEW", "POINT", "FIRST" };
char **cp[] = { c+3, c+2, c+1, c };
char ***cpp = cp;
main() {
printf("%s", **++cpp);
printf("%s ", *--*++cpp+3);
printf("%s", *cpp[-2]+3);
printf("%s\n", cpp[-1][-1]+1);
}
If this is not ugly code, then I don't know what is lol ...
Still no good inspiration to come up with something of my own heh
#include <stdio.h>
char *c[] = { "ENTER", "NEW", "POINT", "FIRST" };
char **cp[] = { c+3, c+2, c+1, c };
char ***cpp = cp;
main() {
printf("%s", **++cpp);
printf("%s ", *--*++cpp+3);
printf("%s", *cpp[-2]+3);
printf("%s\n", cpp[-1][-1]+1);
}
If this is not ugly code, then I don't know what is lol ...
Still no good inspiration to come up with something of my own heh
Ok, here's something I came up with : the goal is to find the bug in the wollowing code (if you want to keep it a tad more challenging, don't use a compiler :)) :
#include <stdio.h>
#define BUCKET 10
#define NICE_GARDEN 4
typedef enum { MAPLE = 1, LAVENDER, BLUEBERRY, ROSE, BIRCH, POPPY, AZALEA, PINE, TULIP, OAK } seeds;
int result(char* garden) {
return strlen(garden) - NICE_GARDEN;
}
int main(void) {
char *garden[] = { "tree", "plant", "flower", "shrub" };
int seed = BIRCH & TULIP;
int water = BUCKET / 5;
(result(*(garden+seed)+wat er)>0)?pri ntf("woohe e !!"):printf("try again ...");
printf("\n");
return 0;
}
I don't know if I've hidden it too good or if it's too obvious though ... what do you thinl lol
#include <stdio.h>
#define BUCKET 10
#define NICE_GARDEN 4
typedef enum { MAPLE = 1, LAVENDER, BLUEBERRY, ROSE, BIRCH, POPPY, AZALEA, PINE, TULIP, OAK } seeds;
int result(char* garden) {
return strlen(garden) - NICE_GARDEN;
}
int main(void) {
char *garden[] = { "tree", "plant", "flower", "shrub" };
int seed = BIRCH & TULIP;
int water = BUCKET / 5;
(result(*(garden+seed)+wat
printf("\n");
return 0;
}
I don't know if I've hidden it too good or if it's too obvious though ... what do you thinl lol
try this one
not as good as ur programs!
#include <stdio.h>
int main() {
int x = 1;
int y = 1;
int z = 1;
printf("x(%d) == y(%d) == z(%d) ==> ", x, y, z);
if (x == y == z) printf("true\n");
else printf("false\n");
x = y = z = 2;
printf("x(%d) == y(%d) == z(%d) ==> ", x, y, z);
if (x == y == z) printf("true\n");
else printf("false\n");
x = 1; y = z = 0;
printf("x(%d) == y(%d) == z(%d) ==> ", x, y, z);
if (x == y == z) printf("true\n");
else printf("false\n");
return 0;
}
not as good as ur programs!
#include <stdio.h>
int main() {
int x = 1;
int y = 1;
int z = 1;
printf("x(%d) == y(%d) == z(%d) ==> ", x, y, z);
if (x == y == z) printf("true\n");
else printf("false\n");
x = y = z = 2;
printf("x(%d) == y(%d) == z(%d) ==> ", x, y, z);
if (x == y == z) printf("true\n");
else printf("false\n");
x = 1; y = z = 0;
printf("x(%d) == y(%d) == z(%d) ==> ", x, y, z);
if (x == y == z) printf("true\n");
else printf("false\n");
return 0;
}
ASKER
All good! Thanks guys!
Lets see if we can find some that would fit on a T-Shirt? :-)
An emoticon or two would look good. I keep trying (_?+:-) but it doesnt want to work.
Paul
Lets see if we can find some that would fit on a T-Shirt? :-)
An emoticon or two would look good. I keep trying (_?+:-) but it doesnt want to work.
Paul
Here is something small, but it should be improved a bit.
#include <stdio.h>
int main(){
int O=30,*_=&O;
printf("%d %% of C programmers have a problem with pointers\n",
O-O - *_+ *_+ *_* 8) ;} /* :)) */
#include <stdio.h>
int main(){
int O=30,*_=&O;
printf("%d %% of C programmers have a problem with pointers\n",
O-O - *_+ *_+ *_* 8) ;} /* :)) */
ASKER
Hi cwwkie,
Looking good! Clever too, the use of '_'. How about something even more succinct? How about:
int O=30,*_=&O; O= O-O - *_+ *_+ *_* 8) ;} /* :)) */
That looks short, punchy, and has lots of smiles in it. :-)
Can anyone improve on that?
The double use of *_+ seems not to fit in a way but without it there isnt really enough to it. Can anyone think of some more emoticons we can fit in? There's a whole bunch here:
https://www.experts-exchange.com/questions/21445662/Need-more-emoticons.html
Paul
Looking good! Clever too, the use of '_'. How about something even more succinct? How about:
int O=30,*_=&O; O= O-O - *_+ *_+ *_* 8) ;} /* :)) */
That looks short, punchy, and has lots of smiles in it. :-)
Can anyone improve on that?
The double use of *_+ seems not to fit in a way but without it there isnt really enough to it. Can anyone think of some more emoticons we can fit in? There's a whole bunch here:
https://www.experts-exchange.com/questions/21445662/Need-more-emoticons.html
Paul
#include <stdio.h>
int main(int argc, char *argv[])
{
char msg[] = "I cannot read C code.";
return argc + printf("%c", msg[argc==4?0:(main(argc== 1?23:argc= =11?7:argc -1,0)-4)]) ;
}
int main(int argc, char *argv[])
{
char msg[] = "I cannot read C code.";
return argc + printf("%c", msg[argc==4?0:(main(argc==
}
Errm, I forgot to write the non-code portion of my post:
What I'd like to see on a t-shirt is some code that does the opposite of (or something different than) what it seems to do, as all good C code does, as we all know.
This little recursive code is an extension on this idea, and I fear might be as close as I can get.
Ultimately, I'd want a piece of code as simple as:
char msg[] = "I cannot read C code.";
printf("%s", msg);
to output something like "I can read C code.", due to a comma or another simple syntax twist that cannot be easily noticed at first sight. Unfortunately, C has a rather straightforward syntax, and [I think] such a twist can only be hidden in obfuscation. (Or using the preprocessor, maybe?)
What I'd like to see on a t-shirt is some code that does the opposite of (or something different than) what it seems to do, as all good C code does, as we all know.
This little recursive code is an extension on this idea, and I fear might be as close as I can get.
Ultimately, I'd want a piece of code as simple as:
char msg[] = "I cannot read C code.";
printf("%s", msg);
to output something like "I can read C code.", due to a comma or another simple syntax twist that cannot be easily noticed at first sight. Unfortunately, C has a rather straightforward syntax, and [I think] such a twist can only be hidden in obfuscation. (Or using the preprocessor, maybe?)
>> Can anyone improve on that?
Dunno if it improves it, but added some more :
#include <stdio.h>
int main(){
int O=30,*_=&O,o=-80,Y=10;
printf("%d %% of C programmers have a problem with pointers\n",
O-O - *_+ *_* (Y) ?-( ~o ,o) :o) ;} /* :)) */
The sole '-' bothers me a bit ... heh
It should be possible to make some kind of "story", or "scene" with the emoticons, so it doesn't even look like code ...
btw, did anyone find the bug in the code from my last post ? I'm curious :)
Dunno if it improves it, but added some more :
#include <stdio.h>
int main(){
int O=30,*_=&O,o=-80,Y=10;
printf("%d %% of C programmers have a problem with pointers\n",
O-O - *_+ *_* (Y) ?-( ~o ,o) :o) ;} /* :)) */
The sole '-' bothers me a bit ... heh
It should be possible to make some kind of "story", or "scene" with the emoticons, so it doesn't even look like code ...
btw, did anyone find the bug in the code from my last post ? I'm curious :)
ASKER
Hi Infinity08,
A 'bug' is not a 'bug' if you intended it to happen :-)
However:
(result(*(garden+seed)+wat er)>0)?pri ntf("woohe e !!"):printf("try again ...");
becomes
(result(*(garden+1)+water) >0)?printf ("woohee !!"):printf("try again ...");
becomes
(result("plant"+5)>0)?prin tf("woohee !!"):printf("try again ...");
becomes
(result("")>0)?printf("woo hee !!"):printf("try again ...");
becomes
(result("")>0)?printf("woo hee !!"):printf("try again ...");
becomes
(-4>0)?printf("woohee !!"):printf("try again ...");
becomes
printf("try again ...");
I think?
Paul
A 'bug' is not a 'bug' if you intended it to happen :-)
However:
(result(*(garden+seed)+wat
becomes
(result(*(garden+1)+water)
becomes
(result("plant"+5)>0)?prin
becomes
(result("")>0)?printf("woo
becomes
(result("")>0)?printf("woo
becomes
(-4>0)?printf("woohee !!"):printf("try again ...");
becomes
printf("try again ...");
I think?
Paul
Source module for Girfriend 2.x:
#include <stdlib.h>
#include <stdio.h>
Reminder ()
{
printf ("\rGentle Reminder");
}
Upgrade to Wife 1.0:
6c6
< printf ("\rGentle Reminder");
---
> printf ("\rNag............");
Upgrade to Wife 1.1 (Honeymoon Over):
6c6
< printf ("\rNag............");
---
> printf ("\rBitch..........");
:~}
@Paul :
>> I think?
BUCKET/5 equals 2, not 5 ... that should reveal the bug hehe :)
I just start to realise how disappointing it is lol ... should have come up with something better :)
>> I think?
BUCKET/5 equals 2, not 5 ... that should reveal the bug hehe :)
I just start to realise how disappointing it is lol ... should have come up with something better :)
Could abuse trigraphs and make things really whacky... :)
#define Z "%" "c"
#define z Z Z Z
main() {
char x[] =
"Do you speak C?\n." Z z Z z Z z;
# define V \
-10-10-10-1-1
0 ??( x ??) = 6[z]; *
x += 3;
printf(x + 17, x ??( 0 ??( x ??) ??) V, 9 ??( x ??), 7 ??( x ??),
x ??( 16 ??),
x ??( 16 ??),
x ??( 2 ??),
x ??( 13 ??),
x ??( 14 ??),
x ??( 14 ??),
x ??( 11 + 0 ??( x ??) ??), 14 ??( x ??), 15 ??( x ??), V);
??>
#define Z "%" "c"
#define z Z Z Z
main() {
char x[] =
"Do you speak C?\n." Z z Z z Z z;
# define V \
-10-10-10-1-1
0 ??( x ??) = 6[z]; *
x += 3;
printf(x + 17, x ??( 0 ??( x ??) ??) V, 9 ??( x ??), 7 ??( x ??),
x ??( 16 ??),
x ??( 16 ??),
x ??( 2 ??),
x ??( 13 ??),
x ??( 14 ??),
x ??( 14 ??),
x ??( 11 + 0 ??( x ??) ??), 14 ??( x ??), 15 ??( x ??), V);
??>
> Could abuse trigraphs
Like that. But I'm afraid having that on your T-Shirt might look like you can't afford a t-shirt designer with a modern computer ;)
At least I have never used it since I learned C almost 15 years ago.
Like that. But I'm afraid having that on your T-Shirt might look like you can't afford a t-shirt designer with a modern computer ;)
At least I have never used it since I learned C almost 15 years ago.
funny things are always funny
#include <stdio.h>
int main(){
int ______,_______,________,__ _______,__ ________,_ __________ ;
int $;
printf("%d",$-__________-$ );
printf("%d", $*________*$ );
printf("%d", $+______+$ );
int ____________,_____________ ,_________ _____,____ __________ _;
}
#include <stdio.h>
int main(){
int ______,_______,________,__
int $;
printf("%d",$-__________-$
printf("%d", $*________*$ );
printf("%d", $+______+$ );
int ____________,_____________
}
int main()
{
/*
(*_*) ('_')
| ---' '---|
/\ /\
*/
}
even you can try this simply;
{
/*
(*_*) ('_')
| ---' '---|
/\ /\
*/
}
even you can try this simply;
@srinims : I'm curious ... what's the $ supposed to do ?
nothing it's just a varaible;
It's not a valid variable afaik ... only letters, digits and _ are allowed ... or am I missing something ?
I haven't faced any problem in microsoft compiler.
weird ... :) oh well, never mind me :)
> > what's the $ supposed to do ?
> I haven't faced any problem in microsoft compiler.
It seems to be Microsoft Specific in C++: http://msdn2.microsoft.com/en-us/565w213d.aspx
But not in C: http://msdn2.microsoft.com/en-us/e7f8y25b(VS.80).aspx
> I haven't faced any problem in microsoft compiler.
It seems to be Microsoft Specific in C++: http://msdn2.microsoft.com/en-us/565w213d.aspx
But not in C: http://msdn2.microsoft.com/en-us/e7f8y25b(VS.80).aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> Guess what I've wasted most of today's valuable time on
:)
Very nice. I think it is much better than the Perl Camel T-shirt you are referring to.
:)
Very nice. I think it is much better than the Perl Camel T-shirt you are referring to.
ASKER
i aib_42,
That is AWESOME! You've gotta have full points for that one! Does it assume any particular CPU or is it cross-platform?
Thanks all! But you've got to agree its impressive and fits the question perfectly.
Paul
That is AWESOME! You've gotta have full points for that one! Does it assume any particular CPU or is it cross-platform?
Thanks all! But you've got to agree its impressive and fits the question perfectly.
Paul
ASKER
Hi again aib,
It also has an artistic colour pattern when seen with syntax colouring! :-)
Paul
It also has an artistic colour pattern when seen with syntax colouring! :-)
Paul
>Very nice. I think it is much better than the Perl Camel T-shirt you are referring to.
Thanks. I've also noticed for the first time today that the Perl code contains some broken-up keywords such as
"ev al".
>That is AWESOME! You've gotta have full points for that one!
Woah, thanks :).
>Does it assume any particular CPU or is it cross-platform?
I think it's pure ANSI-C with the exception of non-left-justified preprocessor directives. (I did make sure they were on their own lines, though.) What does gcc say?
(MSVS and lcc-win32 compile without any warnings for me)
I should get a t-shirt printed while I'm still excited about this :)
Thanks. I've also noticed for the first time today that the Perl code contains some broken-up keywords such as
"ev al".
>That is AWESOME! You've gotta have full points for that one!
Woah, thanks :).
>Does it assume any particular CPU or is it cross-platform?
I think it's pure ANSI-C with the exception of non-left-justified preprocessor directives. (I did make sure they were on their own lines, though.) What does gcc say?
(MSVS and lcc-win32 compile without any warnings for me)
I should get a t-shirt printed while I'm still excited about this :)
That's indeed awesome !! When are you bringing that T-shirt on the market ? :) I'll buy it for sure !
ASKER
>>I'll buy it for sure !
Me too!
Me too!
Somehow, this URL fits into this discussion really well. Or not. :~}
Kent
http://www.youtube.com/watch?v=BovQyphS8kA
ASKER
ROTFL :-)
This certainly leaves a lot to the imagination. A single printf() that produces a saying seems blase, so it would appear that the humor is in the code. Well, at least Sunny's code. :)
Oh, this will rot a few minds:
if (!True ())
False ();
else
Maybe ();
Or maybe a full program that's really stupid:
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <ctype.h>
#define print printf
int mode = 0;
char Buffer[120];
char *p;
int main ()
{
while (fgets (Buffer, 120, stdin))
{
if (0==1)
//1
print ("ing");
do // ne
//0
{}
while (0==1);
if (memcmp (Buffer, "//0", 3) == 0)
{ mode = 0; continue; }
if (memcmp (Buffer, "//1", 3) == 0)
{ mode = 1; continue; }
if (mode == 1)
for (p = Buffer; *p; ++p)
if (isalpha (*p) || *p == '\n')
fputc (*p, stdout);
}
}
May this will help kickstart things. :)
Kent