我使用dll从C程序运行一些Fortran源代码。我想在Fortran中使用**CALL GETCWD(DIRNAME)**来访问文件。当前工作目录(CWD)是Fortran dll所在的目录还是C代码所在的目录?
kpbwa7wx1#
#include <errno.h> #include <stdio.h> #include <unistd.h> #define PATH_SIZE 0x0200 int main() { char buf[PATH_SIZE]; if (getcwd(buf, PATH_SIZE) == NULL) { printf("Error %d getting CWD\n", errno); return 1; } printf("CWD: [%s]\n", buf); return 0; }
输出:
[cfati@cfati-5510-0:/mnt/e/Work/Dev/StackOverflow/q054306561]> ~/sopr.sh ### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ### [064bit prompt]> ls code00.c [064bit prompt]> gcc -o cwd code00.c [064bit prompt]> [064bit prompt]> ls code00.c cwd [064bit prompt]> ./cwd CWD: [/mnt/e/Work/Dev/StackOverflow/q054306561] [064bit prompt]> [064bit prompt]> pushd .. && ./q054306561/cwd && popd /mnt/e/Work/Dev/StackOverflow /mnt/e/Work/Dev/StackOverflow/q054306561 CWD: [/mnt/e/Work/Dev/StackOverflow] /mnt/e/Work/Dev/StackOverflow/q054306561 [064bit prompt]> [064bit prompt]> mkdir test && pushd test && ../cwd && popd /mnt/e/Work/Dev/StackOverflow/q054306561/test /mnt/e/Work/Dev/StackOverflow/q054306561 CWD: [/mnt/e/Work/Dev/StackOverflow/q054306561/test] /mnt/e/Work/Dev/StackOverflow/q054306561
1条答案
按热度按时间kpbwa7wx1#
输出: