Well your program works perfect, but your form is a little off:
Instead of this:
Code:
using std::string;
using std::cout;
using std::cin;
using std::endl;
Most ppl would just use
Code:
using namespace std;
But I don't know how your book teaches you so I won't press my point.
Also it is "bad practice" to right
if statements like this:
Code:
if (input1 == input2)
cout << "The strings are the same size. \n\n" << endl;
if (input1 > input2)
cout << "String 1 is bigger. \n\n" << endl;
if (input1 < input2)
cout << "String 2 is bigger. \n\n" << endl;
It would be better to write it like this:
Code:
if (input1 == input2)
cout << "The strings are the same size. \n\n" << endl;
else if (input1 > input2)
cout << "String 1 is bigger. \n\n" << endl;
else if (input1 < input2)
cout << "String 2 is bigger. \n\n" << endl;
Again if you havent learned about else if statements I won't pressure you ur book will cover it in due time, but there are a couple of good reasons to use else if statements:
It Creates faster code at run time. When you use
else if statements and an evaluation proves true for 1 if the subsequent
else if statements would not be executed. In your code unnecessary evaluations would still be carried on after a preceding if statement proves true. While speed may not be a big concern for a small program like yours, these little slow-downs add up in larger programs and can cause noticeable differences at runtime. The best way to keep this from happening later on is to practice it now when your just learning it. Because its hard to remember the little details like this when ur working on a large project if you don't already know them inside and out.
Ok well good code and everything btw if you want to see something cool try this. Choose option 1. Type 20 a's for the first string and 1 "z" for the second string. String 2 will be longer because when you compare the size of strings it compares their values lexicographically (that's alphabetically) Just so you know its the alphabetical order and NOT the physical size (in memory) of the string.
Here's my edited version of your program: Hope u don't mind ;P