Изменение:
int main(int argc, char *argv[])
{
int i;
char *directory;
char *name;
//Iterate through command line arguments
for (i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--directory"))
{
memcpy(directory, argv[i + 1], sizeof (argv[i + 1]));
continue;
}
else if (!strcmp(argv[i], "-n") || !strcmp(argv[i], "--name"))
{
memcpy(name, argv[i + 1], sizeof (argv[i + 1]));
continue;
}
}
...
до:
#include <limits.h>
int main(int argc, char *argv[])
{
int i;
char directory[PATH_MAX];
char name[PATH_MAX];
//Iterate through command line arguments
for (i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--directory"))
{
strcpy(directory, argv[i + 1]);
continue;
}
else if (!strcmp(argv[i], "-n") || !strcmp(argv[i], "--name"))
{
strcpy(name, argv[i + 1]);
continue;
}
}
...