home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1991
/
04
/
morrow
/
util.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-09-03
|
794b
|
78 lines
/***
* GASystem
* Mike Morrow
* September 1989
***/
/**
* Utilities
**/
#include <ctype.h>
#include <stdio.h>
#include "util.h"
#if __STDC__
#include <stdlib.h>
#endif
#ifndef randnum
/**
* Generate a random number between [0, x - 1]
**/
int randnum(x)
int x;
{
#ifdef unix
return (int) (random() % x);
#else
return (int) (rand() % x);
#endif
}
#endif
char *eatblanks(s)
char *s;
{
while(isspace(*s)) s++;
return s;
}
void fatal(s)
char *s;
{
fprintf(stderr, "Fatal error: %s\n", s);
exit(1);
}
void warning(s)
char *s;
{
fprintf(stderr, "Warning: %s\n", s);
fflush(stderr);
}
void strupper(s)
char *s;
{
while(*s)
{
if(islower(*s))
*s = toupper(*s);
s++;
}
}