Thread: what header files for these directives?

  1. #1
    Registered User
    Join Date
    Apr 2008

    what header files for these directives?

    Dear All,
    i have copied the code from CBOARD FAQ section to find the current working dir...but my compiler showing header file not found??
    i am using window 2000 operating system
    #include <sys/param.h> 
    #include <unistd.h> 
    #include <stdio.h> 
    int main(void)
      char buf[MAXPATHLEN];
      if( getcwd( buf, MAXPATHLEN ) ) 
        printf( "%s\n", buf );
      return 0;
    could any body help me correct header files for me?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    <sys/param.h> and <unistd.h> are not standard C headers, but POSIX standard headers (I think, having never actually read that standard), and consequently not available in Windows except via Cygwin and (not in all cases) MinGW.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Join Date
    Dec 2007
    Probably depends on the development environment. Google "msdn getcwd" if you're using Visual Studio.

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    Depending on your compiler... for example for VS6 I have
    #include <stdio.h> 
    #include <windows.h>
    #include <DIRECT.H>
    int main(void)
      char buf[MAX_PATH];
      if( getcwd( buf, sizeof buf ) ) 
        printf( "&#37;s\n", buf );
      return 0;
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    Ė David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Confusion on header and source files
    By dnguyen1022 in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2009, 03:42 AM
  3. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 12:21 PM
  4. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM