/**************************************************************************** * cs50.h * * version 1.1.5 * * Computer Science 50 * Glenn Holloway * David J. Malan * * Declarations for CS50's library. * Based on Eric Roberts' genlib.h and simpio.h. * * The latest version of this file can be found at * http://cs50.net/pub/releases/cs50/cs50.h. * * To compile as a static library on your own system: * % gcc -c -ggdb -std=c99 cs50.c -o cs50.o * % ar rcs libcs50.a cs50.o * % rm -f cs50.o * % cp cs50.h /usr/local/include * % cp libcs50.a /usr/local/lib ***************************************************************************/ #ifndef _CS50_H #define _CS50_H #include #include /* * Borrow the standard library's data type for Boolean variables whose * values must be (true|false). */ #include /* * Our own data type for string variables. */ typedef char *string; /* * Reads a line of text from standard input and returns the equivalent * char; if text does not represent a char, user is prompted to retry. * Leading and trailing whitespace is ignored. If line can't be read, * returns CHAR_MAX. */ char GetChar(void); /* * Reads a line of text from standard input and returns the equivalent * double as precisely as possible; if text does not represent a * double, user is prompted to retry. Leading and trailing whitespace * is ignored. For simplicity, overflow and underflow are not detected. * If line can't be read, returns DBL_MAX. */ double GetDouble(void); /* * Reads a line of text from standard input and returns the equivalent * float as precisely as possible; if text does not represent a float, * user is prompted to retry. Leading and trailing whitespace is ignored. * For simplicity, overflow and underflow are not detected. If line can't * be read, returns FLT_MAX. */ float GetFloat(void); /* * Reads a line of text from standard input and returns it as an * int in the range of [-2^31 + 1, 2^31 - 2], if possible; if text * does not represent such an int, user is prompted to retry. Leading * and trailing whitespace is ignored. For simplicity, overflow is not * detected. If line can't be read, returns INT_MAX. */ int GetInt(void); /* * Reads a line of text from standard input and returns an equivalent * long long in the range [-2^63 + 1, 2^63 - 2], if possible; if text * does not represent such a long long, user is prompted to retry. * Leading and trailing whitespace is ignored. For simplicity, overflow * is not detected. If line can't be read, returns LLONG_MAX. */ long long GetLongLong(void); /* * Reads a line of text from standard input and returns it as a string, * sans trailing newline character. (Ergo, if user inputs only "\n", * returns "" not NULL.) Leading and trailing whitespace is not ignored. * Returns NULL upon error or no input whatsoever (i.e., just EOF). */ string GetString(void); #endif