I have a problem with 'cin >>'

I've made my own version of "Lost fortune" but when I put a 'string' instead of a 'value' after 'cin >>' it skips the next 'cin >>' and changes the 'string' in a 'value'. How can I fix this?? (I use visual studio 2015)

// Lost Fortune
//

#include "stdafx.h"
#include <iostream>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

int main()
{
const int GOLD_PIECES = 900;
int adventurers, killed, survivors, leader, enemies, alliance;

//get information
cout << "Welcome to Lost Fortune" << endl;
cout << "\nPlease enter the following for your peronalised adventure" << endl;

cout << "Enter a number: ";
cin >> adventurers;

cout << "Enter another number (smaller than prvious number): ";
cin >> killed;

survivors = adventurers - killed;

cout << "Enter you nickname: ";
cin >> leader;

cout << "Enter a group name: ";
cin >> alliance;

cout << "Enter a enemy group name: ";
cin >> enemies;

//Writing the adventure
cout << "\nA brave group of " << adventurers << ", known as " << alliance << ", set out to a quest. \nIt was a dangerous quest that nobody ever dared to pursue. ";
cout << "\nIt was a quest to find the lost treasure of the Ancients. \nThe group was led by the infamous " << leader << "." << endl;

cout << "Along the way " << alliance << " encountered " << enemies << ", a great battle was fought but " << alliance << " had the upperhand." << endl;
cout << enemies << " was defeated, but at a cost." << endl;
cout << "Of the " << adventurers << " adventurers, " << killed << " got killed, leaving just " << survivors << " in the group." << endl;

int extraGold = GOLD_PIECES % survivors;
int shares = GOLD_PIECES / survivors;

cout << "The " << survivors << " continued their quest and after a long and tough journey they found the lost fortune." << endl;
cout << alliance << " split the 900 pieces of gold, so every living member got " << shares << " gold." << endl;
cout << leader << " took the extra " << extraGold << " to keep things fair of course" << endl;

return 0;
}
Topic archived. No new replies allowed.