windows环境中用的头文件<windows.h>和<system.h>都不是c++中都文件,而是windows系统中都,所以在类unix系统中当然就不能用啦~
上mac环境下都代码:
#include "iostream"
#include <unistd.h>
using namespace std;
int main(int argc, char** argv)
{
const int MAXPATH=250;
char buffer[MAXPATH];
getcwd(buffer, MAXPATH);
printf("The current directory is: %s", buffer);
}
---------------------------------------------------
我正在处理的程序的路径竟然是:/Users/show_me_a_bit/Library/Developer/Xcode/DerivedData/testopenCV-ckobicrvyqfjbsbwpzlycvzpepoq/Build/Products/DebugProgram
这么深,还是隐藏路径(command+shift+。显示隐藏文件)。在操作文件读写时还是带上绝对路径吧,默认路径真让人头大。