I've been doing the tutorials here and after the basic in/out figured I could apply my knowledge to a new program. I'm compiling after each in/out step I want so i can see more how it works and also so I can manage any mistakes I might make.
so as a musician I made it something somewhat useful to me, this program takes 12 numbers as it's input (related to atonal music), and then the user should be able to do different operations on that set of number (reverse order, inverting the values, adding the same number to all, etc...). (PS. I am aware that using an array would be a better way of managing all 12 numbers, and I hope to change that when I get up to that point.)
So, the problem is that I can enter the 12 numbers and that works fine. But when it asks for what operation I want to do, the program prints the question and the answer (without the variable printed ) and ends without letting me enter it.
I included comments to help you figure out what I'm talking about. According the tutorials everything should be working fine. I've tried a few different things based on what the tutorial says, but nothing works.
Please help!
Thanks!
-Mike
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string operation;
int a, b, c, d, e, f, g, h, i, j, k, l;
cout << "Enter the tone row, separated by spaces.\n";
cin >> a >> b >> c >> d >> e >> f >> g >> h >> i >> j >> k >> l;
\\ up to here works as expected
\\ this next section is what is not working
\\ it works if I isolate this section by deleting the above 3 lines of code
cout << "which operation would you like to perform? (R, I, RI)\n";
getline (cin, operation);
cout << "you selected " << operation << ".\n";
That would be because you used a getline, I think. I'm just a newbie myself, but it looks like you want to use a switch statement.
case a: cout << "You selected a." << endl;
break;
etc. This is probably not the most efficient way to do what you want it to, but it was the only thing I could think of. By the way, your string "operation" doesn't do anything. You'll probably want to write a function called "operation" instead of putting it as a string.