im trying to pass a file as an argument to my code and I cant get the name of the file to match the file path on CLion. Basically, when I try to open the file for reading, it ends up being null (probably a path error). I tried putting the absolute path into the fopen function and it works just fine. The text file is located in the same folder as the .c file. Any advice on this?
char* inputFile = argv[1];
char* outputFile = argv[2];
int start = atoi(argv[3]);
int end = atoi(argv[4]);
char *target = argv[5];
char *replacement = argv[6];
if (start > end || start < 1 || end < 1)
{
return 1;
}
char line[102];
FILE *input = fopen(inputFile, "r"); # input is NULL
# if you change the variable inputFile to the absolute path of the file instead,
# the program runs just fine
while(fgets(line, 102, input))
{
printf("x");
}