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 8569723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:24:09+00:00 2026-06-11T18:24:09+00:00

I have created some C++ classes in C++ Builder. I am now using these

  • 0

I have created some C++ classes in C++ Builder. I am now using these in a VCL forms application. I have a function that loads a text file and takes a string as an argument.

I am using an openDialog control to browse to the file to then open it up.

My problem is this: The .filename property of the openFialog is in the form of UnicodeString and my function needs a std::string. How can I convert a unicode string to a std::string?

Here is my code:

OpenDialog1->Execute();
calCalendar.loadAppointmentsFromFile(OpenDialog1->FileName.t_str());

Here is the function definition:

void loadAppointmentsFromFile(const std::string& stringFilename);

I am getting the following error:

[BCC32 Error] Assessment2.cpp(39): E2342 Type mismatch in parameter ‘stringFilename’ (wanted ‘const std::string &’, got ‘wchar_t *’)

Can I please have some help to rectify this problem?

  • 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-11T18:24:10+00:00Added an answer on June 11, 2026 at 6:24 pm

    Use UnicodeString::t_str to get a narrowed string. However, you should consider not mixing the two.

    Another option is to convert to an AnsiString first:

    AnsiString str = OpenDialog1->FileName;
    std::string s(str.c_str());
    loadAppointmentsFromFile(s);
    

    Or

    std::string s = OpenDialog1->FileName.t_str(); // TCHAR mapping set to char
    loadAppointmentsFromFile(s);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created some custom JPanel classes using the NetBeans GUI Builder. Next, I
I have created a project that uses scala that has some abstract classes definitions
I have some shaped created using flex primitive classes like ellipse , rectangle, path
I have authored some custom classes that I would like to create using XAML:
I have created some tests in my WPF application. Right now I am working
I have some NSManagedObject classes created for use with CoreData I need to add
So I have a chunk of code that declares some classes, creates data, uses
I have created some JQuery that will expand a div 'popup' on hover and
I have created some functional categories that I use to show/hide markup elements. However,
I'm new to Servlet containers and have created a web application using Tomcat 6.0.26.

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.