You should execute sh -c echo $PWD
; generally sh -c
will execute shell commands.
(In fact, system(foo)
is defined as execl("sh", "sh", "-c", foo, NULL)
and thus works for shell built-ins.)
If you just want the value of PWD
, use getenv
, though.