#include <algorithm>
#include <iostream>
#include <Windows.h>
#include <string>
#include <cctype>
using namespace std;

int main(void)
{
	//declare variables
	char npcname;
	char actid;

	//askin the user to input npc name
	cout << "Please Enter Your NPC Name!"<<endl;
	cin >> npcname;
	//askin the user to input action id
	cout << "Please Enter Your NPC ActionID!"<<endl;
	cin >> actid;
	while (!isdigit(actid))
	{
		cout << "You must enter a number for your ActionID"<<endl;
		cin>> actid;
	}

	cout <<"worked";


}

when i type the NPC name it's check if the npcname is digit or not while the while loop should check if the accid is digit or not HOW COME -.-!!!?

You're working with single characters rather than strings. Try changing the type of npcname and actid from char to std::string. Also note that the loop won't work too well with strings. You probably want to check all characters.

You're working with single characters rather than strings. Try changing the type of npcname and actid from char to std::string. Also note that the loop won't work too well with strings. You probably want to check all characters.

#include <algorithm>
#include <iostream>
#include <Windows.h>
#include <string>
#include <cctype>
using namespace std;

int main(void)
{
	//declare variables
	string npcname;
	string actid;

	//askin the user to input npc name
	cout << "Please Enter Your NPC Name!"<<endl;
	cin >> npcname;
	//askin the user to input action id
	cout << "Please Enter Your NPC ActionID!"<<endl;
	cin >> actid;
	while (!isdigit(actid[0]))
	{
		cout << "You must enter a number for your ActionID"<<endl;
		cin>> actid;
		cout << actid;
	}

	cout <<"worked";


}

worked bt if i typed a number at the beging it will work how can i stop it?

You also may want to read up on strings and string input, from what I read from multiple other sources, you want to be using the standalone function getline(cin, npcname) vs the regular cin >> input. Mixing cin >> with strings may give some funky results.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.