rename() only works for directory that program is running in?
问题 I am trying to rename a bunch of files in a user specified directory, but it only seems to be working when the user specifies the directory that the program is running from. For example, when running from the command line: ./a.out . "NewName.txt" will work, while ./a.out .. "NewName.txt" will not work. Is there a reason for this? It's on Linux, by the way. int main(int argc, char** argv){ char* dirpath = argv[1]; char* newName = argv[2]; DIR *d; struct dirent *dir; d = opendir(dirpath); if (d