That's because scanf %s only returns the first token. Therefore there's nothing for strtok to find as the second and third arguments. Fgets returns the whole line. You still need to protect against using the args pointers for cases with fewer than three tokens. For example, just modifying your existing code:
Code:
printf("There are %d arguments\n", args);
printf("Command is %s\n", com);
if (arg1) printf("File1 is %s\n", arg1);
if (arg2) printf("File2 is %s\n", arg2);