I'm new to C programming. I've been practicing use of command line arguments in C. I've written a C code to calculate the area and circumference of a circle. This is my code:
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
float circle(float pi,int r)
{
float cir;
cir=(pi*r*r);
printf("area of the circle is: %f \n",cir);
}
float circumference(float pi,int r)
{
float circum;
circum=(2*pi*r);
printf("the circumference is: %f \n",circum);
}
int main(int argc,char *argv[])
{ int r,r1;
float pi;
r=0;
pi=M_PI;
if(argc>3 || argc<3)
{
printf("error \n");
exit(0);
}
r=atoi(argv[1]);
r1=atoi(argv[2]);
circle(pi,r);
circumference(pi,r1);
}
My results are proper but I want to enhance my code to stop if the argument given is not a number. if not it should be an error. How can I do it? Any leads will be appreciated. Thank you in advance
isdigit.