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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:44:10+00:00 2026-06-09T16:44:10+00:00

I was trying to make the connection between python string and C character array

  • 0

I was trying to make the connection between python string and C character array assignment to string literals.
For example:

char* word="Hello";
        word="Now";

assigns to the character String “Hello” placed in read only memory location. And now a reassignment of word to “Now” means a now the character array is assigned a memory location corresponding to “Now”.

In python even numbers (and obviously strings) seem to work like that with a being assigned a memory location with value 2 and then reassigned a memory location with value 3.

 a=2
 a=3

This contrasts with C where for almost all variable assignments the variable contains the value it is assigned. Am I making a good comparison here?

  • 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-09T16:44:11+00:00Added an answer on June 9, 2026 at 4:44 pm

    In C, char * is the type “pointer to character.” A pointer is like a “handle” that gives you access to the value itself. When you assign word = "Now";, you are changing the handle, not the characters of the string. Both "Hello" and "Now" still exist as groups of bytes in constant storage.

    Python hides more of what it’s doing, but internally its built-in string references essentially act like pointers. So your observation is correct up to a point.

    The big difference in strings of these languages is that in Python all strings are immutable. C lets you manipulate (by assignment) characters within a (non-constant) string. For example:

    char word [] = "Hello";
    // word is now the name of a 6-character (including final null) mutable string
    word[0] = 'h';
    // Now word has the value "hello".
    

    In Python, you would have to create a completely new string:

    word = 'h' + word[1:]
    

    Here the bytes that make up the new string are different than those of word.

    You are right that Python has “reference semantics”. Everything behaves as though you are manipulating a handle rather than a value.

    >>> a=[1]
    >>> b=a
    >>> a
    [1]
    >>> b
    [1]
    >>> a[0]=5
    >>> a
    [5]
    >>> b
    [5]
    

    Here the assignment b = a copied a handle or reference to the list. The list itself is not copied. This is evident because changing the first element of a also changed b.

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

Sidebar

Related Questions

Iam trying to make a connection between my database on the MYSQL(iam using the
I'm trying to make a connection to a SQL Server Express DB on localhost,
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm trying to make a simple chat program between to programs on a lan.
I'm trying to create a 2D array to represent a weighted graph. To make
I have made a database structure where users can make friend connection between them
I'm trying to manage a connection between my phone and another bluetooth device. I'm
I'm trying to make a communication between a PHP page and running Java server.
I'm trying make a login window where a user is prompted to enter their
I'm trying make an entity with doctrine that has three associations with other entities

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.