How to do i prevent an input of a decimal number in the code below

int main(int argc, char *argv[])
{

if(argc == 3)
{
int ConvertToDec( char number[], int base);
int base2 , no , i=0 ;
char b;

char rev[30] ;
char arr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',};

base2 = atoi(&argv[2][1]);
no = atoi(argv[1]); <----------- If this a a decimal no. how to make cout
something else
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main(int argc, char *argv[])
{

if(argc == 3)
{
int ConvertToDec( char number[], int base);
int base2 , no , i=0 ;
char b;

char rev[30] ;
char arr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',};

base2 = atoi(&argv[2][1]);
if (!strchr(argv[1], '.') no = atoi(argv[1]);
/*something else*/ 

This will assing a value to no only if no dot is found in argv[1], which means that the number is not decimal.
If your question is how to prevent a user from inputting a base-10 number, you can't.
Topic archived. No new replies allowed.