Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use the MSDN example with the create ComboBox but I have a problem with this

C++
wcscpy_s(A, sizeof(A)/sizeof(TCHAR), (TCHAR*)Planets[k]);


the Compiler says ..
||=== Build: Debug in ComboBox (compiler: GNU GCC Compiler) ===|
|In function 'void ComboBox(HWND)':|
|39|error: 'wcscpy_s' was not declared in this scope|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I add the <cstring> and even the <wchar> to load the funcions, but is not working either with these 2 headers

What I have tried:

Anyone knows how to bring this to the light :| ?
Posted
Updated 10-Jul-20 5:15am

wcscpy_s is declared in string.h on Windows, but may not be in gcc; try wcscpy. Also, you should not be using TCHAR for wcscpy_s, as it is Unicode only. If you want your code to be ASCII/Unicode configurable than use tcscpy_s.
 
Share this answer
 
Comments
M@gelearn 10-Jul-20 10:07am    
I changed to wcscpy but it take only 2 arguments.. and yes I tryed even string.h but is not declared on gcc. I used TCHAR cause I just copy the example from the MSDN, but they don't specify headers and on which compiler is working. So in other words I have to use the wcscpy and forget about the TCHAR as it works for Unicode only..
Thanks again Richard..
Richard MacCutchan 10-Jul-20 10:27am    
The MSDN documentation is aimed at Windows programmers using the Microsoft compilers. If you are using gcc then you should check with the GNU documentation. If you are running on Linux then use the 'man' command.
In my opinion, the whole strcpy_s family of API was just dumb and redundant. You can use strncpy or wcsncpy and accomplish the same thing.
C++
wcsncpy( A, (TCHAR*)Planets[k], sizeof(A) - 1 );
The -1 will leave room for the null termination.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900