SimpleCxxLib
package#include "simpio.h"
Functions | |
Reads a complete line from cin and scans it as an integer. | |
Reads a line of text from cin and returns that line as a string. | |
Reads a complete line from cin and scans it as a floating-point number. |
int getInteger(string prompt = "");
cin
and scans it as an
integer. If the scan succeeds, the integer value is returned. If
the argument is not a legal integer or if extraneous characters
(other than whitespace) appear in the string, the user is given
a chance to reenter the value. If supplied, the optional
prompt
string is printed before reading the value.
Usage:
int n = getInteger(prompt);
double getReal(string prompt = "");
cin
and scans it as a
floating-point number. If the scan succeeds, the floating-point
value is returned. If the input is not a legal number or if
extraneous characters (other than whitespace) appear in the string,
the user is given a chance to reenter the value. If supplied, the
optional prompt
string is printed before reading the value.
Usage:
double x = getReal(prompt);
string getLine(string prompt = "");
cin
and returns that line
as a string. The newline character that terminates the input is
not stored as part of the return value. If supplied, the optional
prompt
string is printed before reading the value.
Usage:
string line = getLine(prompt);