title: Get the current working directory in C on windows
body: <p>For some bizarre reason, when I try to use the function get_current_dir_name with MinGW GCC compiler,
  I get this result on linkage:</p>
  
  <pre><code>undefined reference to `get_current_dir_name'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  
  <p>But, I get this only when using the function like this  </p>
  
  <pre><code>printf("%i", get_current_dir_name());
  </code></pre>
  
  <p>or this</p>
  
  <pre><code>printf("%s", get_current_dir_name());
  </code></pre>
  
  <p>When I try to do </p>
  
  <pre><code>printf(get_current_dir_name());
  </code></pre>
  
  <p>I get this, which makes no sense, because the function returns a char *, according to docs:</p>
  
  <pre><code>tester.c: In function 'main':
  tester.c:16:2: warning: passing argument 1 of 'printf' makes pointer from integer without a cast [enabled by default]
    printf(get_current_dir_name());
    ^
  In file included from tester.c:1:0:
  c:\mingw\include\stdio.h:294:37: note: expected 'const char *' but argument is of type 'int'
   _CRTIMP int __cdecl __MINGW_NOTHROW printf (const char*, ...);
  </code></pre>
  
  <p>Google seem to really dislike talking about C, because I can find how to get the workdir on almost any existing language, except C. The only thing that pops up are some docs, which describe 3 functions: getcwd, getwd, and get_current_dir_name. I really want to use the get_current_dir_name one because of it's cleanness.</p>
  
  <p>How do I deal with this? Is this a minGW bug? Or am I missing something?</p>