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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:00:42+00:00 2026-05-20T16:00:42+00:00

How do I concatenate Strings with C/C++? I tried the following ways: PS: errorInfo

  • 0

How do I concatenate Strings with C/C++?

I tried the following ways:

PS: errorInfo is a char * I should return it.

        errorInfo = strcat("Workflow: ", strcat(
            workflowToString(workflow).utf8(), strcat(" ERROR: ",
                    errorCode.utf8)));

        sprintf(errorInfo, "Workflow %s ERROR: %s",
            workflowToString(workflow).utf8(), errorCode.utf8());

        errorInfo = "Workflow: " + workflowToString(workflow).utf8() + " ERROR: " + errorCode.utf8;

Just the sprintf compiles but when running my application crash.

PS: I’m using NDK from Android

  • 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-20T16:00:42+00:00Added an answer on May 20, 2026 at 4:00 pm

    According to this page strcat does the following:

    Appends a copy of the source string to the destination string. The terminating null character in destination is overwritten by the first character of source, and a new null-character is appended at the end of the new string formed by the concatenation of both in destination.

    In your implementation, however, "Workflow: " is a constant string. You cannot modify that string, which is what strcat would do. In order to do that, create a string like:

    char message[1000];
    strcpy(message, "Workflow: ");
    strcat(message, "other string");
    ....
    

    However, be careful about the utf8 character encoding because one utf8 code point could be multiple chars long.

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

Sidebar

Related Questions

i want to concatenate 2 strings in c++, i can't use char*. I tried
I've just tried the following, the idea being to concatenate the two strings, substituting
What's the most efficient way to concatenate strings?
What would be your preferred way to concatenate strings from a sequence such that
Someone told me that it's faster to concatenate strings with StringBuilder. I have changed
I am looking for a way to concatenate the strings of a field within
How do I concatenate together two strings, of unknown length, in COBOL? So for
How do you concatenate bits in VHDL? I'm trying to use the following code:
I'm trying to concatenate 3 [char(32)] fields: title1 title2 title3 into one field, but
I try to use VIM build my SQL query by concatenate block of strings.

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.