我用了
 char curpath[50]; 
 getcwd(curpath,50);
 为什么会有错误: error C2065: 'getcwd' : undeclared identifier
 

解决方案 »

  1.   

    GetCurrentDirectory
    The GetCurrentDirectory function retrieves the current directory for the current process. DWORD GetCurrentDirectory(
      DWORD nBufferLength,  // size of directory buffer
      LPTSTR lpBuffer       // directory buffer
    );
      

  2.   

    CString CYourClass::GetAppPath()
    {
    char szFileName[256];
    GetModuleFileName(NULL,szFileName,256);
    char szDrive[256]={0};
    char szDir[256]={0};
    char szPath[256]={0};
    _tsplitpath(szFileName,szDrive,szDir,NULL,NULL);
    CString str;
    str.Format("%s%s",szDrive,szDir);
    return str;
    }返回exe文件所在的路径,如 debug 文件夹或者 release 文件夹。