What does this C code do?

Here’s a challenge for you! Who want’s to compile the C code below and see what happens? I’ve only tested it in Linux. It’s amazing what this small snippet of code can do. Will bring back memories of a 68k based computer.

This isn’t nasty code or anything like that.

Compile using this command

cc eastman.c -lm -o eastman

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Save the file as eastman.c */
 
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <sys/ioctl.h>
 
             main() {
         short a[4];ioctl
      (0,TIOCGWINSZ,&a);int
    b,c,d=*a,e=a[1];float f,g,
  h,i=d/2+d%2+1,j=d/5-1,k=0,l=e/
 2,m=d/4,n=.01*e,o=0,p=.1;while (
printf("\x1b[H\x1B[?25l"),!usleep(
79383)){for (b=c=0;h=2*(m-c)/i,f=-
.3*(g=(l-b)/i)+.954*h,c<d;c+=(b=++
b%e)==0)printf("\x1B[%dm ",g*g>1-h
*h?c>d-j?b<d-c||d-c>e-b?40:100:b<j
||b>e-j?40:g*(g+.6)+.09+h*h<1?100:
 47:((int)(9-k+(.954*g+.3*h)/sqrt
  (1-f*f))+(int)(2+f*2))%2==0?107
    :101);k+=p,m+=o,o=m>d-2*j?
      -.04*d:o+.002*d;n=(l+=
         n)<i||l>e-i?p=-p
             ,-n:n;}}

I found the code here. Try not to take a look at that link until you have compiled the code – you don’t want to spoil the surprise.

Post in the comments below of what you see!

One thought on “What does this C code do?

Leave a Reply