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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:03:20+00:00 2026-05-30T23:03:20+00:00

So if I do: char * a = hello; hello is stored in the

  • 0

So if I do:

char * a = "hello";

“hello” is stored in the RODATA section and a points to it. If I do:

char a[10] = "hello";

“hello” is stored on the STACK in an array of 10 bytes called a.

What happens when I do:

char * a[10] = {"hello", "hi"}

So, we have an array of 10 character pointers which will be stored on the STACK. But what about the string literals? Do they go in the RODATA section?
Also, does the same thing happen with argv?

  • 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-30T23:03:21+00:00Added an answer on May 30, 2026 at 11:03 pm
    char *a[10] = {"hello", "hi"}
    

    The elements of the array are pointers to string literals. As any string literal they are also non-modifiable and the implementation can store them in read-only memory.

    *a[0] = 'g';   // undefined behavior, modifying a string literal
    a[0] = "bla";  // ok, modifying the pointer
    

    Now for your second question:

    Also, does the same thing happen with argv?

    No, because they are not string literals. The pointers in argv and the strings pointed to can be modified. This is guaranteed by the C Standard.

    (C99, 5.1.2.2.1p2) “The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program, and retain their last-stored values between program startup and program termination.”

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

Sidebar

Related Questions

char *s = hello; The code above allocates 6 bytes in read-only section of
I have one requirement in C. char abc[]=hello; char hello[]=world; Using abc whether we
I have a string as const char *str = Hello, this is an example
I have the following code in C: char *str = Hello World; char *s
Hello Im trying to get all possible combinations with repetitions of given char array.
I have few questions about string literals in C++. char *strPtr = "Hello" ;
I have a standard char pointer which im trying to cast to a string.
If we have a char *hello - and the string is hello and i
char* p = hello world; programmers usually assigns the address of an variable to
char *s = hello ppl.; for (i = 0; i < strlen(s); i++) {

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.