Hello,

I was doing a test Win32 Project. I am using the standard rename() function under cstdio. My program was not working. So, while tracing, I got the return value of rename function as -1.

I have not seen anywhere, rename(0 function returning -1. Could anyone tell me what's wrong.

Code:

int flag = rename((char *)OldName, (char *)NewName);
\\OldName and NewName are of type wchar_t
\\flag returns -1

Thanks in advance!

wchar_t means wide character. You can't convert a wchar_t to a char by "brute force casting" it. You have to call an appropriate function to convert it. Take a look at wcstombs_s(), additionally there are some Macros for conversion, for example CA2CT.

Comments
Thanks a lot for the valuable info

wchar_t means wide character. You can't convert a wchar_t to a char by "brute force casting" it. You have to call an appropriate function to convert it. Take a look at wcstombs_s(), additionally there are some Macros for conversion, for example CA2CT.

Oh! OK.. I got wcstombs to work. The problem I do while coding is type cast things directly if the complier shows the error - function cannot convert parameter x from xxxx to xxxx.

Thanks for the help dude! Respect to you...

This question has already been answered. Start a new discussion instead.