How to make a program disallow number strings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <iostream>
#include <conio.h>
#include <Windows.h>
#include <string>
#include <stdlib.h>
using namespace std;
void lossfunc(int hhealth, int loss, string heroname, string monster, int monsterhealth, int monsterloss)
{
	int monsterhealthremaining = monsterhealth - monsterloss;
	int healthremaining = hhealth - loss;
	cout << heroname << " has " << hhealth << " health, after the attack he has " << healthremaining << " health remaining!\n";
	cout << monster << " has " <<monsterhealth << " health, after the attack he has " << monsterhealthremaining << " health remaining!\n";
}
	
void main()
{	
		string heroname;	
	std::cout << "Type in the name of the Hero  =  ";
	getline(cin, heroname);
	
		string monster;
	cout << "Type in the name of the Monster  =  ";
	getline(cin, monster);
	
		int hhealth;
	std::cout << "Type in the Hero's maximum amount of health  =  ";
	std::cin >> hhealth;	

		int loss;
	std::cout << "Type in the amount of health the Hero will lose  =  ";
	std::cin >> loss;	
	
		int monsterhealth;
	cout << "Type in the Monster's maximum amount of health  =  ";
	cin >> monsterhealth;

		int monsterloss;
	cout << "Type in the amount of health the Monster will lose  =  ";
	cin >> monsterloss;
	
		int mhr = monsterhealth - monsterloss;
		int hhr = hhealth - loss;
		
if (mhr <= 0 && hhr <= 0)
	cout << "Stalemate!\n";
		else if (mhr <= 0)
			cout << heroname << " wins! ";
		else cout << monster <<" wins! ";


	lossfunc(hhealth, loss, heroname, monster, monsterhealth, monsterloss);
	_getch();


}



The part I'm talking about is the first 2 string things (heroname and monster).
How do I make the program NOT accept numbers in those strings? Please keep in mind that what is written in this program is basically all I know about C++.
Help please? :c
Look at all the characters in your string, you can determine whether or not they're a digit by calling the function isdigit():

http://www.cplusplus.com/reference/std/locale/isdigit/
Topic archived. No new replies allowed.