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

  • Home
  • SEARCH
  • 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 8498199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:20:14+00:00 2026-06-11T00:20:14+00:00

I have a few straightforward questions:- Is the following correct according to a normal

  • 0

I have a few straightforward questions:-

  1. Is the following correct according to a normal c++ compiler?

    int arr[3][4];
    void func(int *a, int m, int n)
    {
     int i,j;
     cin>>i>>j; 
     cout<< a[i*n + j]; //is this way of addressing correct provided 0<=i<m and 0<=j<n
    } 
    
    int main()
    {
     func((int*)arr, 3,4);
    }
    
  2. If the bounds of an array strictly has to be a constant expression, why doesn’t the following generate compiler errors?

    int func(int m, int n)
    {
     int arr[m][n]; //m and n are not known until run time
    }
    
  • 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-11T00:20:16+00:00Added an answer on June 11, 2026 at 12:20 am

    Is the following correct according to a normal c++ compiler?

    Yes, because the Standard specifies that even arrays with more than 1 dimensions are contigous in memory. BUT! You’re misunderstanding array indexing and length a bit – i and j have to be strictly less than 3 and 4, respectively. The 3 and 4 are the sizes of the array in its two dimensions, and not the maximal possible subscripts.

    If the bounds of an array strictly has to be a constant expression, why doesn’t the following generate compiler errors?

    Maybe you’re using a compiler that supports this as an extension (think of GCC, Clang, etc.)

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

Sidebar

Related Questions

I have few questions about ssis transction isolation levels. consider a scenario:I have an
I have few basic questions on session management in GWTP. Now, we create a
I have few basic questions on session management in GWTP. Client : GWTP, Server
I have few pages in following structure. --Project |---WebContect |----Admin/ * |----Author/ * |----Readonly/
We have few components like libraries dlls When initially created I ran the following
Straightforward question: I have a few variables that are doubles. I would like to
I have a few questions related to the design of my User class but
i have few confusion regarding ORM(Object Relational Mapping) i am thinking about to use
I have few controls (Label, Custom Textbox, Datagridview) docked on a form. When I
I have few text fields like SSN , phone number and email id. 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.