DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T g

⟦edd6098bb⟧ TextFile

    Length: 1238 (0x4d6)
    Types: TextFile
    Names: »getwd.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Hangman1/getwd.c« 

TextFile

/* getwd.c
 * gets word, and if debug defined prints the word
 * written by: ritcv!jxs7451
 */
#include "hangman.h"
#include<stdio.h>

getwd(word, length)
char word[];
int *length;
{
   long getrand();           /* random number generator */
   int fd;                   /* file descriptor */
   int i;                    /* everyday array counter */
   int flag=0;               /* flag==1 if need to get new word */
   char ch;                  /* 1 character buffer */

   fd = open(WORDL,0);
   lseek(fd,getrand(),0);    /* goto offset position */
   for (read(fd,&ch,1);ch != '\n';read(fd,&ch,1)); /* skip to next word */
   for (read(fd,&ch,1),i=0;ch != '\n';read(fd,&ch,1),i++)
      word[i] = ch;
   close(fd); 
   word[i] = '\0';

   for (i=0;word[i] != '\0';i++)     /* mapping caps to smalls */
      if ((word[i] >= 'A') && (word[i] <='Z'))
         word[i] -= ('A' - 'a');
   if ((i-2) < *length) /* i-2 is length of the word */
      flag++;

   for (i=0;word[i] != '\0';i++) /* checking for non lowercase */
      if ((word[i] < 'a') || (word[i] > 'z'))
      {
         flag++;  /* set flag */
         break;   /* exit loop */
      }

   if (flag) /* checking if need to get another word */
      getwd(word, length);
}