After exchaning email with Jason, what he wants to do is to change directory to the current user's home directory. That can be done very easily with: uid = getuid(); pwd = getpwuid(uid); if (pwd) { chdir(pwd->pw_dir); } The password structure contains the user's home directory in pw_dir. On 2 Apr 2000, at 23:10, Jeffrey Taylor wrote:
If I understand what you want, there is a function called getcwd, (GET Current Working Directory) that does what you want. (see program at end) It is not ANSI standard C. It works with SuSE 6.1, YMMV. I've installed additional libraries and upgraded a few. I suspect it is available on most systems.
HTH, Jeffrey
Quoting jason
: ok i'm desperate and kan't find an answer.
Does anyone know how 2 get the directory of the programming currently running. ie, fubar (the app) is stored in /usr/bin i do: cd / fubar
output should be "/usr/bin"
how would i do this. I've tried everything i can think of and everything in my books and i still can't get it to work. btw it's in c
============================= cut here ============================= #include
int main(int argc, char *argv[]) { printf("%s\n", getcwd()); }
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
-- Jerry Feldman Contractor, eInfrastructure Partner Engineering 508-467-4315 http://www.testdrive.compaq.com/linux/ Compaq Computer Corp. 200 Forest Street MRO1-3/F1 Marlboro, Ma. 01752 -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/