H4x0

Get Current Directory

May 8th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <direct.h>
  3. #include <stdlib.h>
  4.  
  5. char* currentDirectory() {
  6.     char* buffer;
  7.  
  8.     if((buffer = _getcwd(NULL, 0)) == NULL) {
  9.         perror("Unable to find current directory");
  10.     } else {
  11.       return buffer;
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment