由买买提看人间百态

topics

全部话题 - 话题: arcbelly
(共0页)
w****a
发帖数: 155
1
来自主题: Unix版 - a "chdir" problem in C program
我在写一个system call 的程序, 主要是用chdir实现改变当前目录,程序如下:
#include
#include
using namespace std;
int main()
{
char* path ="/home/ugrad1/arcbelly";
char* buf ;
buf = new char[256];
chdir(path);
getcwd(buf,256);
cout << buf << endl;
return 0;
}
执行完这个程序后,当前目录应该变到 /home/ugrad1/arcbelly
但是输出结果确是:
/home/ugrad1/arcbelly
The "temp" directory is my original one, so this means that this program
doesn't change the current directory. I think the "chdir" might not work.
请帮我看看是
(共0页)