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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:11:01+00:00 2026-06-07T18:11:01+00:00

Clarification : Given that a string literal can be rewritten as a const char[]

  • 0

Clarification: Given that a string literal can be rewritten as a const
char[]
(see below), imposing a lower max length on literals than on
char[]s is just a syntactic inconvenience. Why does the C standard
encourage this?


The C89 standard has a translation limit for string literals:

509 characters in a character string literal or wide string literal (after concatenation)

There isn’t a limit for a char arrays; perhaps

32767 bytes in an object (in a hosted environment only)

applies (I’m not sure what object or hosted environment means), but at any rate it’s a much higher limit.

My understanding is that a string literal is equivalent to char array containing characters, ie: it’s always possible to rewrite something like this:

const char* str = "foo";

into this

static const char __THE_LITERAL[] = { 'f', 'o', 'o', '\0' };
const char* str = __THE_LITERAL;

So why such a hard limit on literals?

  • 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-07T18:11:03+00:00Added an answer on June 7, 2026 at 6:11 pm

    The limit on string literals is a compile-time requirement; there’s a similar limit on the length of a logical source line. A compiler might use a fixed-size data structure to hold source lines and string literals.

    (C99 increases these particular limits from 509 to 4095 characters.)

    On the other hand, an object (such as an array of char) can be built at run time. The limits are likely imposed by the target machine architecture, not by the design of the compiler.

    Note that these are not upper bounds imposed on programs. A compiler is not required to impose any finite limits at all. If a compiler does impose a limit on line length, it must be at least 509 or 4095 characters. (Most actual compilers, I think, don’t impose fixed limits; rather they allocate memory dynamically.)

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

Sidebar

Related Questions

I will phrase the problem in the precise form that I want below: Given
So I was given this code: execlp(sh, sh, -c, string, (char*) 0); In class,
Clarification/summary for the question -- we're looking for: a hosted bug tracking system, that
Just need some quick clarification I have 2 Queries in my Access Database that
I need some clarification. I have a Reportwriter dll that uses Crystal Reports. It
I am developing a C# app that can NOT connect to the internet. This
Given that they generate the Create , Read , Update , and Delete (CRUD)
I am designing a simple internal framework for handling time series data. Given that
For clarification, are you able to use MySQL this way to sort? ORDER BY
(Edited for clarification) My (non-OSGi) application build is in Gradle, and I am trying

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.