get_long_long - prompts user for a line of text from stdin and returns the equivalent long long
#include <cs50.h>
long long get_long_long(const char *format, ...);
Prompts user for a line of text from standard input and returns the equivalent long long; if the text does not represent a long long or would cause overflow, user is reprompted.
The prompt is formatted like printf(3).
This function will be deprecated in favor of get_long(3).
Returns the long long equivalent to the line read from stdin in [LLONG_MIN, LLONG_MAX). If line can’t be read, returns LLONG_MAX.
/** * Returns the difference of two long longs read from stdin, or LLONG_MAX if there was an error. */ long long subtract_long_longs(void) { // read long long from stdin long long i = get_long_long("Enter a long long: "); // make sure we read one successfully if (i == LLONG_MAX) { return LLONG_MAX; } long long j = get_long_long("What do you want to subtract from %lld? ", i); if (j == LLONG_MAX) { return LLONG_MAX; } return i - j; }
get_char(3), get_double(3), get_float(3), get_int(3), get_long(3), get_string(3), printf(3)