'wchar_t *' a 'TCHAR [260]' conversion error

Hi :)

Someone could explain me why this conversion is not correct?

1
2
3
4
5
6
7
8
9
10
int FileSystemExplore(TCHAR *dir,TCHAR* goalstring){
.
.


  TCHAR current_file[MAX_PATH];
.
.

  current_file=_tcsdup(dir);


The error is impossible cast from 'wchar_t *' to 'TCHAR [260]'

Thanks in advance
Last edited on
_tcsdup returns a pointer. You're trying to assign that pointer to an array.
TCHAR is a simple type (char or wchar_t). It is not a class like std::string and does not support assigning a pointer.
Thanks for the answer.
How can i do that? There is a way different from declare current_file as a pointer?
closed account (N36fSL3A)
Check out the strcpy wcscpy function.
Last edited on
Thanks :)
to clarify....
strcpy copies chars
wcscpy copies wchar_ts
_tcscpy copies TCHARs.

Since you are using TCHARs, you will need to use _tcscpy.


Or... better yet... don't use TCHARs. Ever. They're retarded. The "normal" WinAPI functions take TCHAR strings... but you can take normal chars or wchar_ts by adding an 'A' or 'W' to the end of the function name.

IE:
MessageBox <- takes TCHAR strings
MessageBoxA <- takes char strings
MessageBoxW <- takes wchar_t strings
Thanks for the exhaustive response ,it's very useful :)
Topic archived. No new replies allowed.