fopen("~/routz.txt", "r"); ain't working, how can I tell the program that the file is in the home users' directory?
Printable View
fopen("~/routz.txt", "r"); ain't working, how can I tell the program that the file is in the home users' directory?
Without error checks.
Code:char path[1000];
sprintf( path, "%s/%s", getenv("HOME"), "routz.txt" );
fopen( path, "r" );
Or, if "~" works in chdir():
Code:chdir("~");
fopen("./routz.txt", "rt");