I made a program to be able to change the value of four variables (will be shown in the program) at the command line arguments.
int main (int argc, char *argv[])
{
double minx = -1.0;
double maxx = 1.0;
double miny = -1.0;
double maxy = 1.0;
int i;
for (i = 1;i < argc;i++)
{
if (strcmp(argv[i],"-range") == 0)
{
minx = atof(argv[++i]);
maxx = atof(argv[++i]);
miny = atof(argv[++i]);
maxy = atof(argv[++i]);
}
}
this code will work after I compile with cc compiler. Let's say the filename is range.c
cc range.c
a.out -range 1.0 2.0 3.0 4.0
But how do I stop the program (show error message) if less than four values entered, for example
cc range.c
a.out -range 1.0 2.0 3.0
Someone help me please
thank you