summaryrefslogtreecommitdiffstats
path: root/labb8/lib/StanfordCPPLib/simpio.h
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-12-03 17:11:43 +0100
committerGustav Sörnäs <gustav@sornas.net>2020-12-08 10:21:07 +0100
commit0c39051ba80f04b1177833a006f2d442a7170b56 (patch)
tree9e657946a061b5b305f9cf75634db7b37e979eb3 /labb8/lib/StanfordCPPLib/simpio.h
parent7b7f6808a7b2db2ed21103767434c1445f7815c2 (diff)
downloadtddd86-0c39051ba80f04b1177833a006f2d442a7170b56.tar.gz
add initial files l8
Diffstat (limited to 'labb8/lib/StanfordCPPLib/simpio.h')
-rwxr-xr-xlabb8/lib/StanfordCPPLib/simpio.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/labb8/lib/StanfordCPPLib/simpio.h b/labb8/lib/StanfordCPPLib/simpio.h
new file mode 100755
index 0000000..25c32c1
--- /dev/null
+++ b/labb8/lib/StanfordCPPLib/simpio.h
@@ -0,0 +1,53 @@
+/*
+ * File: simpio.h
+ * --------------
+ * This file exports a set of functions that simplify input/output
+ * operations in C++ and provide some error-checking on console input.
+ */
+
+#ifndef _simpio_h
+#define _simpio_h
+
+#include <string>
+
+/*
+ * Function: getInteger
+ * Usage: int n = getInteger(prompt);
+ * ----------------------------------
+ * Reads a complete line from <code>cin</code> 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
+ * <code>prompt</code> string is printed before reading the value.
+ */
+
+int getInteger(std::string prompt = "");
+
+/*
+ * Function: getReal
+ * Usage: double x = getReal(prompt);
+ * ----------------------------------
+ * Reads a complete line from <code>cin</code> 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 <code>prompt</code> string is printed before reading the value.
+ */
+
+double getReal(std::string prompt = "");
+
+/*
+ * Function: getLine
+ * Usage: string line = getLine(prompt);
+ * -------------------------------------
+ * Reads a line of text from <code>cin</code> 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
+ * <code>prompt</code> string is printed before reading the value.
+ */
+
+std::string getLine(std::string prompt = "");
+
+#endif