bool isValidId(int* id)
{
if(log10(*id) != 6)
{
return false;
}
return true;
}
printf("Enter ID: ");
gets(input);
c.id = atoi(input);
validID= isValidId(c.id);
if(!validID)
{
printf("Invalid ID format -(Use example 123456 format). \n");
}
This is how it looks now.I ask the user to enter an ID and check it if is valid with the isValidId method but my program is crashing when I enter an ID. Please help! Thanks
I think this may be a good solution, both easy to read and efficient.
There is no need to acquire its length if you just want to judge if it is a valid id
Program crashes because the parameter of isValidId is pointer to int, not int, so
should be