The command line is parsed into tokens and the information is provided to main() as a pair of arguments that you are ignoring. Declare:
int main(int argc, char *argv[])
{
...
}
That is, argv is an array of string pointers. The first string, argv[0] is not really an argument. It is conventionally the name of the program being run. Your example looks like Unix (or Linux), so argv[0] might well point to something like "\home\Anonymous\a.out" if the full path is used, or "a.out" or "./a.out" might be there. I don't know, and the C standard doesn't say that there's even a program name there. If there are arguments, they are pointed to by argv[1], argv[2], ...
The argc argument is the number of entries in argv[], counting the non-argument in argv[0]. So, argc is always positive and 1 more than the number of actual arguments. On Unix systems, argv[argc] exists and is a 0 (NULL) pointer.
Lecture mode off.
So, use either sscanf() or atof() to convert individual argument strings into doubles.
if (argc != 5)
{
printf("Usage: %s x1 y1 x2 y2\n", argv[0]);
return 1;
}
sscanf(argv[1], "%lf", &x1);
sscanf(argv[2], "%lf", &y1);
sscanf(argv[3], "%lf", &x2);
sscanf(argv[4], "%lf", &y2);
Note the test for the correct number of arguments. You don't want to be subscripting argv for arguments that aren't there. The alternative (no worse if you don't look at sscanf() return values) is atof:
x1 = atof(argv[1]);
y1 = atof(argv[2]);
...and so on.
I use sscanf, mostly, and put it in a function like:
int str2dbl(char *str, double *pdbl)
{
char dummy;
int n = sscanf(str, " %lf %c", pdbl, &dummy);
return (n==1);
}
That does the conversion and returns 1 (true) if successful or 0 (false) if the input didn't look like exactly one numeric value, with perhaps some leading or trailing spaces. You probably don't (yet) need all that bulletproofing, but it's good to know that there are easy standard library tools to get solid input parsing and error testing done.
Have fun!