getwd.c

来自「汇编代码大全」· C语言 代码 · 共 56 行

C
56
字号
/* * 4.2bsd getwd simulation for Sys V.3 */#include <stdio.h>#define SYSV3#define MAXWD 1024	     /* limited by 4.2 getwd(2) */#ifdef SYSV3char *getcwd();char *getwd(path)char *path;{    return(getcwd(path,MAXWD));}#else/* * 4.2bsd getwd simulation for Sys V.2 */#include <stdio.h>#define MAXWD 1024	     /* limited by 4.2 getwd(2) */char *getwd(path)char *path;{     char *nlp;     FILE *fp;     FILE *popen();     char *strrchr();	putenv("IFS= \t\n");     fp = popen("PATH=/bin:/usr/bin pwd", "r");     if (fp == NULL)	     return 0;     if (fgets(path, MAXWD, fp) == NULL) {	     (void) pclose(fp);	     return 0;     }     if ((nlp = strrchr(path, '\n')) != NULL)	     *nlp = '\0';     (void) pclose(fp);     return path;}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?