#include <pwd.h> #include <unistd.h> int main(){ struct passwd *pw; uid_t uid = getuid(); pw = getpwuid(uid); char path[200] = {0}; strcpy(path, pw->pw_dir);//當前用戶的目錄 strcat(path, "/YTLOG"); mkdir(path, S_IRWXU);//建立文件夾,用戶可讀可寫可執行 cout<<"path="<<path<<endl; cout<<"cpu="<<sysconf(_SC_NPROCESSORS_ONLN)<<endl;//拿取當前能夠用的cpu總核數 sysconf(_SC_NPROCESSORS_CONF);//拿取當前全部的cpu總核數 }