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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:05:51+00:00 2026-05-27T11:05:51+00:00

First off, I’m a C# programmer, so my working knowledge of C++ is fairly

  • 0

First off, I’m a C# programmer, so my working knowledge of C++ is fairly limited. I took it back in college, but haven’t touched it in 10 years, so please forgive me if this is relatively simple stuff.

I’m attempting to make a DLL that I can use in C# that implements the libwpd library.

I’ve managed to create a DLL that exports 2 functions that I can access via P/Invoke. The first returns a constant integer (generated by visual studio as a sample), the 2nd a string.

If I return a constant string from the function, it passes successfully to C# and I can read it on the other end, so I know the data is being passed back.

The problem I’m running into is with libwpd. I’ve had to modify their TextDocumentGenerator.cpp file to add the information to a char* instead of using the printf that they use so I can access it later.

I’ve added a variable definition to the public section of the header file so I can read it from the calling code.

Now, I’m trying to write a function that allows me to add the char* given by libwpd to the external char*.

I’ve come up with this:

char* addString(const char* addThis, char* toThis)
{
char* copier  = (char*)malloc(strlen(toThis) + 1 + 1);
strcpy(copier, toThis);
strcpy(copier, "1");

toThis = (char*)malloc(strlen(copier) + 1);
strcpy(toThis, copier);

return copier;
} 

But when I pass the information back, I get a blank string.

I call the function by calling totalFile = addString("\n", totalFile);

(I realize it should only technically add “1” to the string repeatedly, but it’s not doing even that)

If i change the strcpy to strcat for the copier lines, it locks up.

I don’t know how to create a program in C++ so I can even step through the functions to see what’s happening.

Any assistance would be appreciated.

  • 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-27T11:05:51+00:00Added an answer on May 27, 2026 at 11:05 am

    Are you aware of existence of std::string? It’s a class that handles strings in C++; char * is legacy from C.

    std::string provides + operator, that does what you want.

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

Sidebar

Related Questions

First off I've been working with Java's Concurrency package quite a bit lately but
First off, I'm working on an app that's written such that some of your
First off, I did look on google and stackoverflow, but nothing seem to really
first off this is a class assignment so i would appreciate help but just
First off, I think I'm trying to use Spring incorrectly, but confirmation would be
First off: Everything works , but I would like to fine tune this a
First off, I think I know what's going on, but I thought I'd bring
First off, I'm a beginner in mobile development. I've seen many similar questions but
First off, i'd like to say that my programming knowledge is very basic and
First off, I am using Windows XP. I have multiple hard drives and it

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.