triplegolf - not only the source code length counts!
Bash, 23 characters
Error:
bash: /: Is a directory
Source:
echo $0-$01234;/;
Output:
/bin/bash-/bin/bash1234
Brainf*ck, 32 characters
This code executes for about 3 seconds and stops and displays the following error and output.
Error:
bff: out of memory (-2058691272)
Source:
+++++[......-]..+[>>>>>>>>>>>>-]
Output: (Hexdump)
0505 0505 0505 0404 0404 0404 0303 0303
0303 0202 0202 0202 0101 0101 0101 0000
C, 35 characters
Warning:
b.c:1:30: warning: division by zero
Source and Output:
main(){system("cat "__FILE__)/0;;;}
PHP, 50 characters
Warning:
PHP Warning: Division by zero in /tmp/3 on line 1
Source and Output:
<?php echo (0/0).''.file_get_contents(__FILE__);?>
C - 48 chars
main(i){while(++i<49)putchar(i);putchar('\z');}
Note: includes a final (Unix-style) newline.
Output from gcc a.c
reads:
a.c:1:41: warning: unknown escape sequence '\z'
The output from a.out
is mostly non-printing chars, so here's what it looks like after piping through hexdump:
00000000: 0203 0405 0607 0809 0A0B 0C0D 0E0F 1011 ................
00000010: 1213 1415 1617 1819 1A1B 1C1D 1E1F 2021 .............. !
00000020: 2223 2425 2627 2829 2A2B 2C2D 2E2F 307A "#$%&'()*+,-./0z
JavaScript, 63 66
!function x(){console.log(x+'...');eval(Array(33).join('$'))}()
The output is:
function x(){console.log(x+'...');eval(Array(33).join('$'))}...
In Chrome, the error is:
ReferenceError: $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ is not defined