| | |
Rename() function returning unknown vaules
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 40
Reputation:
Solved Threads: 2
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:
Thanks in advance!
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:
cpp Syntax (Toggle Plain Text)
int flag = rename((char *)OldName, (char *)NewName); \\OldName and NewName are of type wchar_t \\flag returns -1
Thanks in advance!
•
•
Join Date: Dec 2007
Posts: 360
Reputation:
Solved Threads: 69
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.
Last edited by jencas; Jun 22nd, 2009 at 8:42 am. Reason: typo correction
If you are forced to reinvent the wheel at least try to invent a better one!
Please use code tags - Please mark solved threads as solved
Please use code tags - Please mark solved threads as solved
•
•
Join Date: Nov 2008
Posts: 40
Reputation:
Solved Threads: 2
•
•
•
•
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.
Thanks for the help dude! Respect to you...
![]() |
Similar Threads
- Date Function not returning variable in main (C++)
- Function Not Returning Value?? (C++)
- Warning: Unknown(): Unable to call () - function does not exist in Unknown on line 0 (PHP)
- Regarding Function Returning a Value. (C)
- How to declare this function? (C)
- How to Rename Multiple Files with Windows Explorer (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: Deleted Repeated Array elements not working
- Next Thread: Editing txt files with c++
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





