diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2011-03-12 01:23:12 -0500 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2011-03-12 01:23:12 -0500 |
commit | bf8950cad0285ee6ab8a896e8d0a30c5fb62c7af (patch) | |
tree | ca6eaedd03128249d84544d6ad077f1498d66e41 /support.cc | |
parent | 96312236d7f0c857efc95871a31857e24ecdc81b (diff) | |
download | sgdisk-bf8950cad0285ee6ab8a896e8d0a30c5fb62c7af.tar.gz |
Version 0.7.0
Diffstat (limited to 'support.cc')
-rw-r--r-- | support.cc | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -31,6 +31,14 @@ using namespace std; +char* ReadCString(char *inStr, int numchars) { + if (!fgets(inStr, 255, stdin)) { + cerr << "Critical error! Failed fgets() in ReadCString()\n"; + exit(1); + } // if + return inStr; +} // ReadCString() + // Get a numeric value from the user, between low and high (inclusive). // Keeps looping until the user enters a value within that range. // If user provides no input, def (default value) is returned. @@ -66,10 +74,7 @@ char GetYN(void) { do { cout << "(Y/N): "; - if (!fgets(line, 255, stdin)) { - cerr << "Critical error! Failed fgets() in GetYN()\n"; - exit(1); - } // if + ReadCString(line, 255); sscanf(line, "%c", &response); if (response == 'y') response = 'Y'; @@ -316,7 +321,7 @@ uint64_t GetInt(const string & argument, int itemNum) { } // GetInt() // Extract string data from argument string, which should be colon-delimited -string GetString(const string & argument, int itemNum) { +string GetString(string argument, int itemNum) { size_t startPos = -1, endPos = -1; while (itemNum-- > 0) { |