Hello im new to C++ and perhaps a big noob in programming in general. anyways ive encountered an error where isdigit doesnt seem to convert the char to int. ive been using a command-line argument of argv which is a char and want to check if what was typed was a number from 1 to 35 because im gonna use the inputted number to be an int and use it to dictate how many circle balls to spawn in an SFML program im to make.
#include <ctype.h>
using namespace std;
int main(int argc, char *argv[])
{
if (argc > 2 || argc < 1)
{
cout << "Invalid Command!" << endl;
}
if (argc == 1)
{
cout << "Please input X number of circles from 1 to 35." << endl;
}
if (argc == 2)
{
if (isdigit(argv[1]))
{
int X = atoi(argv[1]);
if (X >= 1 && X <= 35)
{
//do stuff
}
else
{
cout << "Please input X number of circles from 1 to 35." << endl;
}
}
}
}
Heres what the error says:
error C2664: 'int isdigit(int)' : cannot convert argument 1 from 'char *' to 'int'