Newsgroups: comp.os.parix
From: leo@slowfox.uni-paderborn.de (Leonhard Voos)
Subject: Re: bug in getcwd?
Organization: Universitaet Paderborn, Germany
Date: 9 Feb 1996 11:18:57 +0100
Message-ID: <4ff72h$7r0@slowfox.uni-paderborn.de>

e9282@tc.hsa.nl (D. Wapstra) writes:

>[using PARIX 1.3.1]

>This gives a coredump when running on a PowerXplorer. It runs just fine
>on the host (SUN4):

>#include <stdio.h>

>void main()
>{
>	char *cwd, *getcwd();
>	cwd = getcwd((char *)NULL,64);
>	printf("%s\n", cwd);
>}

The following should work and conforms to ANSI C and POSIX standard:

-------------------------------------------------------------------------------

#include <stdio.h>
#include <unistd.h>

int main()
{
        char cwd[64];

        if (getcwd(cwd, 64) == NULL) {
		perror("pwd");
		exit(1);
	}

        printf("%s\n", cwd);

	return 0;
}

-------------------------------------------------------------------------------

Good luck!


Leo


