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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:13:26+00:00 2026-06-07T10:13:26+00:00

Using pointers string can be initialized to other characters but when once string has

  • 0

Using pointers string can be initialized to other characters but when once string has been defined it cannot be initialized to other characters.What is the reason behind it??

int main()
{
char str1[]="hello";
char *p="hello";
str1="bye";/*error*/
p="bye";/*works*/
}
  • 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-07T10:13:27+00:00Added an answer on June 7, 2026 at 10:13 am

    Arrays are arrays and pointers are pointers. Defining arrays gives the pointer to the allocated array, that is a constant pointer to the location where the array space hass been reserved. That is a concrete address in the lifo stack. So, str1 is a constant pointer value and you cannot change it. You cannot set the value of the address of a different constant string.

    Defining pointers, as char*p, gives you a variable value of an address. And so, you can change de value of the variable p.

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

Sidebar

Related Questions

Possible Duplicate: How to reverse a string in place in c using pointers? I
gcc 4.4.4 c89 Pointers are not the same as arrays. But arrays can decay
I'm using ptr_map for storing different types of pointers. boost::ptr_map<string, any> someMap; I store
I am trying to get up to speed with using shared_ptr, but I can't
Possible Duplicate: How to reverse a string in place in c using pointers? The
I've written a simple string tokenizing program using pointers for a recent school project.
I want to eliminate the process consumed by a decision using pointers to member
I am using C. I am having issues with using pointers for the fscanf
I'm trying to make a program that, using pointers, detects lines in an image
Im trying to shift my array left as efficiently as possible. Im using pointers

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.