C++ program failing to rename a file

I have a C++ program running on Windows XP compiled with Visual C++ 6.0 containing the following code
1
2
3
4
5
6
7
8
9
10
11
12
if (remove(NewName) != 0)
{
errmsg = strerror(errno);
printf("Removal Error: %s\n", errmsg);
}


if (rename(FileName,NewName) != 0)
{
errmsg = strerror(errno);
printf("Rename Error: %s\n", errmsg);
}


and this fails, offering to send a message to Microsoft about the error of my ways.
The file I want to rename(FileName) does exist and the file I want to rename it to(NewName) does not and none of my error messages appear.
Please make suggestions on how I should fix this.
closed account (S6k9GNh0)
Your doing something that the program can't account for and making it crash. It's your fault, most likely not to do with rename.
Topic archived. No new replies allowed.