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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:17:43+00:00 2026-05-27T10:17:43+00:00

Ps: This is more of a conceptual question. I know this makes things more

  • 0

Ps: This is more of a conceptual question.

I know this makes things more complicated for no good reason, but here is what I’m wondering. If I’m not mistaken, a const char* "like this" in c++ is pointing to l and will be automatically zero terminated on compile time. I believe it is creating a temporary variable const char* to hold it, unless it is keeping track of the offset using a byte variable (I didn’t check the disassembly). My question is, how would you if even possible, add characters to this string without having to call functions or instantiating strings?

Example (This is wrong, just so you can visualize what I meant):

"Like thi" + 's';

The closest thing I came up with was to store it to a const char* with enough spaces and change the other characters.

Example:

char str[9];
strcpy(str, "Like thi")
str[8] = 's';

Clarification:
Down vote: This question does not show any research effort; it is unclear or not useful

Ok, so the question has been highly down voted. There wasn’t much reasoning on which of these my question was lacking on, so I’ll try to improve all of those qualities.

My question was more so I could have a better understanding of what goes on when you simply create a string "like this" without storing the address of that string in a const char* I also wanted to know if it was possible to concatenate/change the content of that string without using functions like strcat() and without using the overloaded operator + from the class string. I’m aware this is not exactly useful for dealing with strings in C++, but I was curious whether or not there was a way besides the standard ways for doing so.

string example = "Like thi" + "s"; //I'm aware of the string class and its member functions
const char* example2 = "Like this"; //I'm also aware of C-type Strings (CString as well)

It is also possible that not having English as my native language made things even worst, I apologize for the confusion.

  • 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-27T10:17:44+00:00Added an answer on May 27, 2026 at 10:17 am

    First, there is nothing null terminated, but the zero terminated. All char* strings in C end with '\0'.

    When you in code do something like this:

    char *name="Daniel";
    

    compiler will generate a string that has a contents:

    Daniel\0
    

    and will initialize name pointer to point at it at a certain time during program execution depending on the variable context (member, static, …).

    Appending ANYTHING to the name won’t work as you expect, since memory pointed to by name isn’t changeable, and you’ll probably get either access violation error or will overwrite something else.

    Having

    const char* copyOfTheName = name;
    

    won’t create a copy of the string in question, it will only have copyOfTheName point to the original string, so having

    copyOfTheName[6]='A';
    

    will be exactly as

    name[6]='A';
    

    and will only cause problems to you.

    Use std::strcat instead. And please, do some investigating how the basic string operations work in C.

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

Sidebar

Related Questions

So this question is not so much technical but more sort of conceptual. I
this was more a conceptual question, but I was wondering what the best C#
I have an interesting situation here this time. This more of a conceptual question,
This is more a conceptual question. Here is my current predicament; I am writing
EDIT : this question is very similar to this one but it's more conceptual
this is more of a conceptual question. Is it aceptable/good programming mixing do/while loops
This was more of a conceptual question, but I'll provide a particular instance where
This is more of a conceptual question and not about the underlying programming technique.
This is more of a hypothetical question. I am wondering if anyone knows if/how
I know this sort of question has been asked before , but I still

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.