Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8775191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:44:40+00:00 2026-06-13T18:44:40+00:00

I have the following code snippet that converts a const char * to a

  • 0

I have the following code snippet that converts a const char * to a LPTSTR, however I get linker errors when I compile.

char * pCopy3 = NULL;
    if (sizeof(TCHAR) == sizeof(char))
    {
        size_t size = strlen(words[2].c_str());
        pCopy3 = new char[size + 1];
        strcpy(pCopy3, words[2].c_str());
    }

The linker errors are as follows

Error   19  error LNK1169: one or more multiply defined symbols found   STablUpd.exe    1   1   STablUpd
Error   17  error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * args" (?args@@3PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in maindlg.obj  tabledlg.obj    STablUpd
Error   18  error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * words" (?words@@3PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in maindlg.obj    tabledlg.obj    STablUpd
Error   16  error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > cmdArgs" (?cmdArgs@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in maindlg.obj    tabledlg.obj    STablUpd
Error   13  error LNK2005: "int __cdecl Main_OnInitDialog(struct HWND__ *,struct HWND__ *,long)" (?Main_OnInitDialog@@YAHPAUHWND__@@0J@Z) already defined in maindlg.obj    tabledlg.obj    STablUpd
Error   8   error LNK2005: "int __stdcall Main_DlgProc(struct HWND__ *,unsigned int,unsigned int,long)" (?Main_DlgProc@@YGHPAUHWND__@@IIJ@Z) already defined in maindlg.obj tabledlg.obj    STablUpd
Error   15  error LNK2005: "struct HINSTANCE__ * g_hInstApp" (?g_hInstApp@@3PAUHINSTANCE__@@A) already defined in maindlg.obj   tabledlg.obj    STablUpd
Error   9   error LNK2005: "void __cdecl Main_OnBrowse(struct HWND__ *)" (?Main_OnBrowse@@YAXPAUHWND__@@@Z) already defined in maindlg.obj  tabledlg.obj    STablUpd
Error   10  error LNK2005: "void __cdecl Main_OnClose(struct HWND__ *,int)" (?Main_OnClose@@YAXPAUHWND__@@H@Z) already defined in maindlg.obj   tabledlg.obj    STablUpd
Error   11  error LNK2005: "void __cdecl Main_OnCommand(struct HWND__ *,int,struct HWND__ *,unsigned int)" (?Main_OnCommand@@YAXPAUHWND__@@H0I@Z) already defined in maindlg.obj    tabledlg.obj    STablUpd
Error   12  error LNK2005: "void __cdecl Main_OnDisplay(struct HWND__ *)" (?Main_OnDisplay@@YAXPAUHWND__@@@Z) already defined in maindlg.obj    tabledlg.obj    STablUpd
Error   14  error LNK2005: _WinMain@16 already defined in maindlg.obj   tabledlg.obj    STablUpd
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:44:41+00:00Added an answer on June 13, 2026 at 6:44 pm

    I presume the code snippet you have shown converts std::string to char*. In that case the code is correct and there should be no errors when compiling that code (except strcpy warning).

    You originally asked for char* to LPTSTR conversion. You could do it like this (for UNICODE character set):

    char *test;
    wchar_t *bla=new wchar_t[size];
    swprintf(bla, size, L"%hs", test);
    LPTSTR bla2=bla;
    

    Alternatively if you use multi-byte character set:

    char *test;
    LPTSTR bla2=test;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code snippet that i use to compile class at the run
Following is the code snippet that I have: // Make Auto release pool NSAutoreleasePool
I have this following snippet from c++ code that is used for encryption: EVP_CIPHER_CTX
I have the following code snippet that shows a list of numbers, and highlights
Hi I have the following code snippet. The idea behind it is that I
I have the following Groovy code snippet that is attempting to use operator overloading
I have the following code snippet that produces a compilation error: public List<string> batchaddresses;
Say I have the following code snippet in c# static const bool DO_PERFORMANCE_CODE =
I have the following code snippet that builds chained select boxes based on data
I have the following code snippet which uses'event' My fellow developers argue that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.