Click here to Skip to main content
14,603,442 members
Rate this:
Please Sign up or sign in to vote.
See more:
I use the MSDN example with the create ComboBox but I have a problem with this

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
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
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.
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.
wcsncpy( A, (TCHAR*)Planets[k], sizeof(A) - 1 );
The -1 will leave room for the null termination.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100