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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:14:00+00:00 2026-06-10T15:14:00+00:00

I am reading the book Let us C by Yashavant Kanetkar. In the Array

  • 0

I am reading the book Let us C by Yashavant Kanetkar.

In the Array of Pointers section there is a section of code which is giving me problems:

int main()
{
    static int a[]={0,1,2,3,4}; //-----------(MY PROBLEM)
    int *p[]={a,a+1,a+2,a+3,a+4};
    printf("%u %u %d\n",p,*p,*(*p));
    return 0;
}

What I don’t understand is why has the array a have to be initialized as static. I tried initializing it without the static keyword but I got an error saying “illegal”. Please help.

  • 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-10T15:14:02+00:00Added an answer on June 10, 2026 at 3:14 pm

    C90 (6.5.7) had

    All the expressions in an initializer for an object that has static storage duration or in an initializer list for an object that has aggregate or union type shall be constant expressions.

    And you are initializing an object that has an aggregate type, so the value must be known at compile time and the address of automatic variables are not in that case.

    Note this has changed in C99 (6.7.8/4)

    All the expressions in an initializer for an object that has static storage duration shall be constant expressions or string literals.

    The constraint on object with aggregate or union type has been removed and I’ve not found it placed somewhere else. Your code with static removed should be accepted by a C99 compiler (it is by gcc -std=c99 for instance, which seems to confirm that I’ve not overlooked a constraint elsewhere).

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

Sidebar

Related Questions

I've been reading a book on Zend framework and there's this HTML/PHP code section
I'm reading the book 'Beginning F#', There's a short list for example code, to
I am reading a book in which author used a code like this public
I was reading the book Theory & Problems Of Data Struc (Seymour Lipschuz). Let
XML FILE CODE: <Books> <Book id=1 isbn=123456> <name>Let Us C</name> <authors> <author>Yashwant Kanetkar</author> <author>ABC</author>
I'm reading Expert F# book and I found this code open System.Collections.Generic let divideIntoEquivalenceClasses
Recently, I was reading book about Erlang which has hot deployment feature. The deployment
I am reading some book and I have encountered a piece of code that
While reading a book called Let us C I read that a function showbit()
I'm reading a book written by Julie Lerman on Code First. According to the

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.