/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that outputs the current working directory
after determining the implementation's maximum  pathname length 
relatimve to the root directory.*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main() {
    char *mycwdp;
    long maxpath;
    
    if((maxpath = pathconf("/",_PC_PATH_MAX)) == -1) {
      perror("Could not determine maximum pathname length");
      exit(1);
    } 
    else if((mycwdp = (char *) malloc(maxpath+1)) == NULL) {
      perror("Could not allocate space for directory pathname");
      exit(1);
    }
    else if(getcwd(mycwdp, maxpath) == NULL) {
      perror("Could not get current working directory");
      exit(1);
    }
    printf("Current working directory : %s\n",mycwdp);
}
     
