int main(int argc, char *argv[]) {
int opt= 0;
int start = -1, end = -1;
char *alg,*dir,*graph;
//Specifying the expected options
//The two options s and e expect numbers as argument
static struct option long_options[] = {
{"start",no_argument,0,'s' },
{"end",no_argument,0,'e' },
{"algorithm",no_argument, 0,'a' },
{"directory",required_argument, 0,'d' },
{"graph",required_argument,0,'g' },
{0,0,0,0}
};
int long_index =0;
int i=0,j=0;
size_t size = 1;
while ((opt = getopt_long(argc, argv,"s:e:a:d:h:g:",
long_options, &long_index )) != -1) {
switch (opt) {
case 'd' :
dir = optarg;
if (optarg == NULL)
printf("d option is must");
else if
{
// How to verify the path provided is Correct/existing
}
else
{
// Any more options of error handling on path
provided is available ?
}
The user passes directory path with option -d , How to verify the path is correct or not ?
What else error checking can be included for this ?