#ifndef USERINPUT_H #define USERINPUT_H /// userinput.h provides functions for retrieving user input. /// The functions are named get + placeholder used by printf for the given datatype. /// string -> usergets /// short -> usergethd /// int -> usergetd /// long -> usergetld /// long long -> usergetlld /// unsigned short -> usergethu /// unsigned int -> usergetu /// unsigned long -> usergetlu /// unsigned long long -> usergetllu /// double -> usergetlf /// The provided functions handle validating the user input and ask again for input /// with the given message until it is valid. /// Using the given message usergets asks the user to enter a string repeatedly /// until its length is between minLength and maxLength (both inclusive). /// The obtained string is then returned. /// If you don't want to enforce a minLength or a maxLength you can assign it to NULL. char *usergets(char *message, unsigned long *minLength, unsigned long *maxLength); /// Using the given message usergethd asks the user to enter a short repeatedly /// until it is in the valid range for a short and between min and max (both inclusive) if provided. /// The obtained short is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. short usergethd(char *message, short *min, short *max); /// Using the given message usergetd asks the user to enter an int repeatedly /// until it is in the valid range for an int and between min and max (both inclusive) if provided. /// The obtained int is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. int usergetd(char *message, int *min, int *max); /// Using the given message usergetld asks the user to enter a long repeatedly /// until it is in the valid range for a long and between min and max (both inclusive) if provided. /// The obtained long is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. long usergetld(char *message, long *min, long *max); /// Using the given message usergetlld asks the user to enter a long long repeatedly /// until it is in the valid range for a long long and between min and max (both inclusive) if provided. /// The obtained long is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. long long usergetlld(char *message, long long *min, long long *max); /// Using the given message usergethu asks the user to enter an unsigned short repeatedly /// until it is in the valid range for an unsigned short and between min and max (both inclusive) if provided. /// The obtained unsigned short is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. unsigned short usergethu(char *message, unsigned short *min, unsigned short *max); /// Using the given message usergetu asks the user to enter an unsigned int repeatedly /// until it is in the valid range for an unsigned int and between min and max (both inclusive) if provided. /// The obtained unsigned int is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. unsigned int usergetu(char *message, unsigned int *min, unsigned int *max); /// Using the given message usergetlu asks the user to enter an unsigned long repeatedly /// until it is in the valid range for an unsigned long and between min and max (both inclusive) if provided. /// The obtained unsigned long is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. unsigned long usergetlu(char *message, unsigned long *min, unsigned long *max); /// Using the given message usergetllu asks the user to enter an unsigned long long repeatedly /// until it is in the valid range for an unsigned long long and between min and max (both inclusive) if provided. /// The obtained unsigned long long is then returned. /// If you don't want to enforce a min or max you can assign it to NULL. unsigned long long usergetllu(char *message, unsigned long long *min, unsigned long long *max); /// Using the given message usergetlf asks the user to enter a double repeatedly /// until it is in the valid range for a double, between min and max (both inclusive), /// greater than the given greaterThan and smaller than the given smallerThan. /// The obtained double is then returned. /// If you don't want to enforce a min, max, greaterThan or smallerThan you can assign them to NULL. double usergetlf(char *message, double *min, double *max, double *greaterThan, double *smallerThan); #endif