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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:17:52+00:00 2026-06-08T17:17:52+00:00

Possible Duplicate: What is the difference between char s[] and char *s in C?

  • 0

Possible Duplicate:
What is the difference between char s[] and char *s in C?

Can the statements

char str[]="abcdef"; 

and

char *str="abcdef"; 

be used to explain the char array and string literal in C?
What is relationship between char array and string literal?
What is actually usage of char array except storing a string literal?

  • 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-08T17:17:53+00:00Added an answer on June 8, 2026 at 5:17 pm

    A string literal is an array of char that is not modifiable.

    C99 6.4.5 p2:

    A character string literal is a sequence of zero or more multibyte characters enclosed in double-quotes, as in “xyz”.

    And then, in C99 6.4.5 p5:

    In translation phase 7, a byte or code of value zero is appended to each multibyte
    character sequence that results from a string literal or literals. The multibyte character
    sequence is then used to initialize an array of static storage duration and length just
    sufficient to contain the sequence. For character string literals, the array elements have
    type char, and are initialized with the individual bytes of the multibyte character
    sequence;…

    The draft C11 I have has similar wording. I believe it is worded with “have type char” precisely to allow a string literal to be assigned to char *. However, the standard does go on to say in C99 6.4.5 p6:

    If the program attempts to modify such an array, the behavior is undefined.

    So assignable, but not modifiable.

    A string literal can be used as an initializer for an array of char. From C99 6.7.8 p14:

    An array of character type may be initialized by a character string literal, optionally
    enclosed in braces. Successive characters of the character string literal (including the
    terminating null character if there is room or if the array is of unknown size) initialize the elements of the array.

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

Sidebar

Related Questions

Possible Duplicate: What is the difference between char a[] = “string” and char *p
Possible Duplicate: difference between string object and string literal Let's say I have two
Possible Duplicates: Difference between char *str="STRING" and char str[] = "STRING"? Need some help
Possible Duplicate: What is the difference between char a[] = “string”; and char *p
Possible Duplicate: Difference between int[] array and int array[] I was sure that this
Possible Duplicate: What is the difference between char s[] and char *s in C?
Possible Duplicate: What is the difference between char s[] and char *s in C?
Possible Duplicate: Difference between string and StringBuilder in c# What’s the difference between System.String
Possible Duplicate: Difference between single quote and double quote string in php Hi all
Possible Duplicate: What is the difference between char s[] and char *s in C?

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.