#ifndef _MYIO_C_H #define _MYIO_C_H #include #include #include /***************************************************** * * * File Name: myio_c.h * * Author: Brenda Sonderegger (all functions) * * Contents: * * get_int() * * get_int_low() * * get_int_bound() * * get_float() * * get_float_bound() * * get_float_low() * * get_random() * * my_gets() * * * *****************************************************/ /***************************************************** * void get_int(int *value) * * Author: Brenda Sonderegger * * Last Modified: Sept. 22, 1998 * * Parameters: single address * * Return value: none * * Side Effect: puts an integer value into the memory * * location specified by the address and * * if an error occurs, the input stream * * is emptied * * Description: guarantees that the input value is an * * integer. Inputs of a, 23c, 2.4 are * * all considered to be illegal * *****************************************************/ void get_int(int *value); /***************************************************** * void get_int_low(int *value, int low) * * Author: Brenda Sonderegger * * Last Modified: Sept. 16, 1998 * * Parameters: single address, and single integer * * Return value: none * * Side Effect: puts an integer value into the memory * * location specified by the address that* * if guaranteed to be greater than or * * equal to the low value * * Description: guarantees that the input value is an * * integer greater than or equal to low * * Functions called: get_int() * *****************************************************/ void get_int_low(int *value, int low); /***************************************************** * void get_int_bound(int *value, int low, int high) * * Author: Brenda Sonderegger * * Last Modified: Sept. 16, 1998 * * Parameters: single address, and two integers * * Return value: none * * Side Effect: puts an integer value into the memory * * location specified by the address that* * if guaranteed to be greater than or * * equal to the low value and less than * * or equal to the high value * * Description: guarantees that the input value is an * * integer greater than or equal to low * * and less than or equal to high * * Functions called: get_int() * *****************************************************/ void get_int_bound(int *value, int low, int high); /***************************************************** * void get_float(float *value) * * Author: Brenda Sonderegger * * Last Modified: Sept. 22, 1998 * * Parameters: single address * * Return value: none * * Side Effect: puts a float value into the memory * * location specified by the address and * * if an error occurs, the input stream * * is emptied * * Description: guarantees that the input value is a * * float. Inputs of a, 23c, 2.4a are * * all considered to be illegal * *****************************************************/ void get_float(float *value); /************************************************************* * void get_float_bound(float *value, float low, float high) * * Author: Brenda Sonderegger * * Last Modified: Sept. 16, 1998 * * Parameters: single address, and two floats * * Return value: none * * Side Effect: puts a float value into the memory location * * specified by the address that is guaranteed to* * be greater than or equal to the low value and * * less than or equal to the high value * * Description: guarantees that the input value is a float * * greater than or equal to low and less than or* * to high * * Functions called: get_int() * *************************************************************/ void get_float_bound(float *value, float low, float high); /***************************************************** * void get_float_low(float *value, float low) * * Author: Brenda Sonderegger * * Last Modified: Sept. 22, 1998 * * Parameters: single address and single float * * Return value: none * * Side Effect: puts a float value into the memory * * location specified by the address and * * if an error occurs, the input stream * * is emptied. The float value is greater* * than or equal to low. * * Description: guarantees that the input value is a * * float. Inputs of a, 23c, 2.4a are * * all considered to be illegal. The * * value is greater than or equal to low * *****************************************************/ void get_float_low(float *value, float low); /***************************************************** * int get_random(int low, int high) * * Author: Brenda Sonderegger * * Last Modified: Sept. 23, 1998 * * Parameters: two integers * * Return value: random integer between low and high * * Side Effect: none * * Description: guarantees that the returned value is * * between low and high inclusively * * Functions called: from stdlib.h * * srand() * * rand() * * from time.h * * time() * * * *****************************************************/ int get_random(int low, int high); /***************************************************** * void my_gets(char *strng, int max_char) * * Author: Brenda Sonderegger * * Last Modified: Oct. 5, 1998 * * Parameters: single array, one integer * * Return value: none * * Side Effect: puts a string of a maximum of max_char* * into the array and adds the null * * terminator to the string. The array * * must be defined to be at least * * max_char + 1 in length * * Description: guarantees that the input string is no* * more than max_char in length excluding* * the null terminator. If the input is * * more than max_char in length, an error* * message is entered, the string is * * truncated, and the input stream is * * cleared. * * * *****************************************************/ void my_gets(char strng[], int max_char); #endif