I know how to read and write to a file, but I am including fopen() in my university project, and we are required to send everything that is required to run the program to the lecturer. But if the directory names change, is there a possibility that my program would not be able to read the file?
int main(void)
{
FILE * fptr;
fptr = fopen("C:\\Users\\username\\Documents\\folder\\filename.txt", "r");
char oneline[MAX_LEN];
while (!feof(fptr))
{
while (fgets(oneline, sizeof(oneline), fptr) != NULL)
printf("%s", oneline);
}
fclose(fptr);
return 0;
}
For example, if my professor downloads the file, and it is kept in downloads instead of documents like the directory I wrote, wouldn't the file be unable to be read? And if so, is there a way for me to make my code "adapt" to the changes in directory?