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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:58:29+00:00 2026-05-13T08:58:29+00:00

How can I add an integer variable to a string and char* variable? for

  • 0

How can I add an integer variable to a string and char* variable? for example:
int a = 5;
string St1 = “Book”, St2;
char *Ch1 = “Note”, Ch2;

St2 = St1 + a –> Book5
Ch2 = Ch1 + a –> Note5

Thanks

  • 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-13T08:58:29+00:00Added an answer on May 13, 2026 at 8:58 am

    The C++ way of doing this is:

    std::stringstream temp;
    temp << St1 << a;
    std::string St2 = temp.str();
    

    You can also do the same thing with Ch1:

    std::stringstream temp;
    temp << Ch1 << a;
    char* Ch2 = new char[temp.str().length() + 1];
    strcpy(Ch2, temp.str().c_str());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 532k
  • Answers 532k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Look for REDIRECT_URL or REDIRECT_STATUS in the $_SERVER global. mod_rewrite… May 17, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer Non jquery reliance will really limit the options nowadays -… May 17, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer Yes there is. It's called SystemClock.sleep(millis). There's also Thread.sleep(millis). I… May 17, 2026 at 12:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Does anyone know how can I add an integer from another table to the
I have a string which holds a decimal value in it and I need
I have a variable that contains a 4 byte, network-order IPv4 address (this was
Can you have a look at the code below and tell me how I
I'm trying to write a class that has a generic member variable but is
I have a com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException in my code (using Hibernate and Spring) and I can't
I'm compiling using Code::Blocks on Windows 7 using the MinGW compiler (which I can
I have the following classes/traits in Scala trait Write[-T] { def add(elem : T);
I have a situation in Python(cough, homework) where I need to multiply EACH ELEMENT
I've been working for some time on (Java) Bytecode, however, it had never occurred

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.