Skip to content
Snippets Groups Projects
workdir.c 362 B
Newer Older
Max Schrötter's avatar
Max Schrötter committed
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

char *mywdfunc(unsigned int bufsize) {
  if (bufsize < 100) {
    return NULL;
  }

  char *buf = (char *)calloc(bufsize,sizeof(char));
  if (buf) {
    getcwd(buf,bufsize-1);
  }

  return buf; 
}

int main() {

  char *ret = mywdfunc(512);

  printf("%s", ret);
  free(ret);
  return EXIT_SUCCESS;
}