1: //TestStuff20160118.cpp
3: #include <iostream>
4: #include <string>
5: using namespace std;
7: #include "GetTwoInts.h"
9: int main(int argc, char* argv[])
10: {
11: //string s = "Hello, world!";
12: //cout << s << endl;
13: //
14: ////Can use length() or size() for number of characters in s
15: //cout << s.length() << endl;
17: ////Can use [] or at() to get a single character
18: //cout << s[1] << endl;
19: //cout << s.at(1) << endl;
21: ////C++ string objects are not immutable
22: //s.at(1) = 'E';
23: //cout << s << endl;
25: ////Two versions of substr()
26: //cout << s.substr(7) << endl;
27: //cout << s.substr(7, 5) << endl;
29: ////Here s1 is also just an array of characters
30: //char s1[] = {'H', 'e', 'l', 'l', 'o'};
31: //for (int i = 0; i < 5; i++)
32: //{
33: // cout << s1[i];
34: //}
35: //cout << endl;
36: //cout << s1 << endl;
38: ////But here s2 *is* a C-string, and so has a '\0' (null character)
39: ////at the end, which allows all the legacy C-string functions in
40: ////<cstring> to work properly with it
41: //char s2[] = "Hello";
42: //for (int i = 0; i < 5; i++)
43: //{
44: // cout << s2[i];
45: //}
46: //cout << endl;
47: //cout << s2 << endl;
49: //atoi() converts a C-string to an integer.
50: //It comes from <cstdlib>.
51: //cout << argv[1] + argv[2] << endl;
52: //cout << atoi(argv[1]) + atoi(argv[2]) << endl;
54: //string s = "Hello, world!";
55: //cout << "w found at index " << s.find('w') << endl;
56: ////The value returned by find() in the following case is string::npos.
57: //cout << "W found at index " << s.find('W') << endl;
59: ////Note the use of string::npos as the value returned by find()
60: ////if the character sought is not in fact found.
61: //if (s.find('W') != string::npos)
62: // cout << "found" << endl;
63: //else
64: // cout << "not found" << endl;
66: //string request;
67: //cout << "Enter your request for action: ";
68: //getline(cin, request);
69: //const string REQUEST_OPTIONS = "qQ";
70: //if (request.length() == 1 && REQUEST_OPTIONS.find(request.at(0)) != string::npos)
71: // cout << "valid" << endl;
72: //else
73: // cout << "not valid" << endl;
74: //cout << "Press Enter to continue ... "; cin.ignore(80, '\n');
76: int a = 5;
77: int b = 10;
78: GetTwoIntValuesFromUser(a, b);
79: cout << a << " " << b << endl;
80: }