UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2003-12-18 04:30 PM

gmukesh
Member
Registered: 2003-12-15
Posts: 4

Re: How does pwd work

any idea how does pwd works internally...suppose I am to write a pwd of my own ..what is the design

Offline

#2 2003-12-18 06:11 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: How does pwd work

Just use getwd(), it's a POSIX function, see man getwd for more info. Can also use the environment variable PWD, try "echo $PWD", can get it with getenv(), but getwd() is much better and safer.

Offline

#3 2003-12-18 08:25 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: How does pwd work

Actually, no, I think getcwd() is the recommended function, and
getwd() is mostly considered deprecated, because it lacks a
length argument (and, will either overflow your buffer, or truncate
at PATH_MAX, on a longer path)...

Offline

#4 2003-12-19 12:24 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: How does pwd work

Offline

Board footer

Powered by FluxBB