#1: PLEASE learn to use code tags, it makes reading your code MUCH easier.
You can edit your post and add them.
http://www.cplusplus.com/articles/jEywvCM9/
#2: Why are you asking for input twice?
std::cin
and
std::getline()
. Rather wasteful since you don't use
mystr at all.
#3: Speaking of strings, where is the
<string>
header? You forgot to include it.
#4: You really don't need the
if
statement in the
case
block, since you create a local
o
variable and assign a value of 9 to it,
if (o > 0)
will always be true.
#5: Your code is Frankenstein, a lot of unnecessary code that does nothing. The
switch
statement is not needed, unless you are planning on having more than one
case
.
Your code could be rewritten as follows and it does much the same as what you likely want it to do (guesswork on my part):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
int main()
{
char rit;
std::cout << "Write liftoff: ";
std::cin >> rit;
std::cout << '\n';
if (rit == 'l')
{
std::cout << "Liftoff!\n";
}
else
{
std::cout << "I SAID WRITE LIFTOFF!!!\n";
}
}
|
Write liftoff: p
I SAID WRITE LIFTOFF!!! |
Write liftoff: l
Liftoff! |