how to check if a command line argument is there in c code example
Example 1: c check if char is an operator
char o = '+'; //Or some other character
if (o == '%' || o == '/' || o == '*' || o == '+' || o == '-') {
//Do something
//...
}
Example 2: check command line input is a number in c
bool isNumber(char number[])
{
int i = 0;
//checking for negative numbers
if (number[0] == '-')
i = 1;
for (; number[i] != 0; i++)
{
//if (number[i] > '9' || number[i] < '0')
if (!isdigit(number[i]))
return false;
}
return true;
}