Ok these kind of bugs are rather obscure, but it relates to your use of cin and gets...
If you take that code, run it, then press these keys: 1 -> 2 -> \13[enter]
The enter breaks the input and reads the number 12 into a. \13 remains on the input.
Next up, it does a gets() which reads the standard input until it finds the newline character, \13... Well that's still there from the previous bit of text entry, so it has that. Then it moves to the next one. gets() is also a function to be avoided because you can't specify maximum length of characters to read, so it's a top target for buffer overflow attacks.
The better and safer way of doing console IO is to use printf() and scanf():
printf
http://www.cplusplus.com/reference/clibrary/cstdio/printf.html
Code:
int a, b, c;
String s1, s2;
printf("String: %s, %i -- %i; %s +-+ %i", s1, a, b, s2, c);
might produce:
Code:
String: bob, 5 -- 6; test +-+ 5
printf() takes an intial parameter as a string. This string specifies the formatting of your output. This formatting string is printed to the output, replacing all %i's, %s's etc with the remaining parameters to the function. In the example, it prints "String: " then there's a %s which means the second paramater to the fuction is a string, and we want that next. Then it prints ", ", then the third parameter which we've said is an integer... etc
scanf
http://www.cplusplus.com/reference/clibrary/cstdio/scanf.html
scanf does exactly the same as printf only in the opposite direction, it'll read from the console input matching against the pattern you give it, then set the values to what you entered.
Code:
int a, b, c;
String s1, s2;
scanf("String: %s, %i -- %i; %s +-+ %i", s1, a, b, s2, c);
If you type into the console "String: bob, 5 -- 6; test +-+ 5" then it will result with:
Code:
a = 5
b = 6
c = 5
s1 = bob
s2 = test