Random dice

Table of Contents

1. org configuration

Explicitly load org languages:

(org-babel-do-load-languages 'org-babel-load-languages
 '((C . t) (shell . t)))

2. RNG Dice

#include <stdlib.h>
#include <time.h>
#include <stdio.h>

int
main(void) 
{
  /* Answer an html requestion with success */
  printf("Status: 200 OK\r\n");
  printf("Content-Type: text/html\r\n");
  printf("\r\n");

  srand(time(NULL));
  int r = 1 + rand() % 6;
  puts("<pre>");
  switch(r) {
  case 1:
    printf("   \n o \n   ");
    break;
  case 2:
    printf("o   \n   \n  o");
    break;
  case 3:
    printf("o   \n o \n  o");
    break;
  case 4:
    printf("o o\n   \no o");
    break;
  case 5:
    printf("o o\n o \no o");
    break;
  case 6:
    printf("ooo\n   \nooo");
    break;
  }
  puts("");
  puts("</pre>");
  return 0;
}
Status: 200 OK
Content-Type: text/html

<pre>
o o
 o 
o o
</pre>

Author: vfts

Created: 2022-11-14 Mon 03:48