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

  • Home
  • SEARCH
  • 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 6042581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:48:23+00:00 2026-05-23T06:48:23+00:00

Sigh I am working with the Microsoft Visual Express C++ IDE. I have recently

  • 0

Sigh

I am working with the Microsoft Visual Express C++ IDE. I have recently transitioned from DevC++ to this IDE.

I have a function that works perfectly in DevC++ but in MSVC++ it wont compile because of Unicode (I think?). What do I need to change to get my function to compile?

See the commented code line for the compiler error I get

map <string, string> GetEvironmentVariablesEx()
{
   map <string, string> envVariables;
   char* environVar = GetEnvironmentStrings();  // Compile error: error C2440: 'initializing' : cannot convert from 'LPWCH' to 'char *'
   char* pos        = strchr( environVar, '\0' );

   // Skip over the "=::=::\0" of the environVar string
   if ( pos != NULL ) { environVar = ++pos; pos = strchr( environVar, '\0' ); }
   else return envVariables;

   while ( true )
   {
       char* delim    = strchr( environVar, '=' );
       if ( delim == NULL )
            break;

       string variable = string( environVar, strlen(environVar)-strlen(delim) );
       string value    = string( ++delim );

       envVariables.insert( pair<string, string>(variable, value) );
       environVar = ++pos;

       // find the "\0\0" that identifies the end of environVar
       if ( pos != NULL && *pos == 0 ) { break; }

       pos = strchr( environVar, '\0' );
   }

   FreeEnvironmentStrings( environVar ); 
   return envVariables;       
}

PS: Because this application is compiled in Unicode, does that mean that it will work on both ANSII computers & UNICODE computers – so my app will able to be run internationally?

  • 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-05-23T06:48:24+00:00Added an answer on May 23, 2026 at 6:48 am

    your project is a UNICODE build and you using ANSI strings, first thing to do is replacing your char variables to TCHAR and try again.

    And as @David Heffernan, aptly suggested, you will have to switch to wstring and aptly change the library functions from standard library which you use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This task has already been asked/answered, but I recently had a job interview that
Sigh I keep getting strange problems with IE 8. I have this <input name=Btn_Edit
On the my page I have html like this: hi<br>bye<br>sigh<br>hello <em>tie</em><br>lie with jquery, how
I'm currently working on a quite big (and old, sigh) code base, recently upgraded
I recently rolled an application that automatically encrypted a file output from another internal
I'm debugging a production application that has a rash of empty catch blocks sigh
Sigh, regex trouble again. I have following in $text : [img]http://www.site.com/logo.jpg[/img] and [url]http://www.site.com[/url] I
Simple, eh? -sigh- A function. Two string arguments ( I guess it doesn't matter
I'm working on a system (ActiveCollab) that uses Smarty for templates. I want to
This may be the most obscure bug I have yet encountered in many years

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.