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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:28:34+00:00 2026-06-13T08:28:34+00:00

There’s one pointer about the following code I can’t figure out: the part in

  • 0

There’s one pointer about the following code I can’t figure out: the part in the function set_array([][9]), why the compiler gives allow this instead the normal full expression set_array([4][9]).However in the main part the int array1[4][9], array1[][9] doesn’t allowed.

#include <stdio.h>
void set_array(int t_array[][9]);
int main(void) {
    int array1[4][9]; // array1[][9] doesn't allowed

    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 9; j++) {
            array1[i][j] = j + 1;
        }
    }
    set_array(array1);
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 9; j++) {
            printf("%d ", *(*(array1 + i) + j));
            //printf("%d ", array1[i][j]);
        }
        puts("\n");
    }
    return 0;

}
void set_array(int t_array[][9]) {
    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 9; j++) {
            t_array[i][j] = 1;
        }
    }   
};

Any explanation about this?

  • 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-13T08:28:35+00:00Added an answer on June 13, 2026 at 8:28 am

    This occurs because when you are doing two different things:

    First you are declaring a variable named array1. In C, the compiler needs to know the amount of space you are declaring to reserve that memory amount to you. So you have to specify the complete size of your array:

    int array1[4][9];

    This way your compiler knows that you need 4 * 9 ints allocated.

    Now, in your function the compiler does not need to know the size of your array (behind of scenes your array is converted to a pointer on your function calls), it needs only to know the size of its elements. So t_array is an pointer to elements of size 9 * sizeof(int). It is because of that you may declare your function the way you’ve declared:

    void set_array(int t_array[][9])

    But it is also possible to declare with all dimension sizes:

    void set_array(int t_array[4][9])

    But it doesn’t matters to the compiler.

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

Sidebar

Related Questions

There's a few previous questions on StackOverflow questioning how one goes about accessing local
There is no doubt that MonoTouch is one of the great cross-compiler(s). Similarly, SenchaTouch
There are nice SO question and answers about this issue, but these options didn't
There are two table s : one is the master and one the detail
There was a similar question posted asking in general about alternatives to Qt. Well,
There is a text file with 1,000,000 lines of code floating around and Ctrl+F
There are a lot of questions about full-joining in mysql(5.1.36). Of course the solution
There is my code that I want to alert test once when mousemove ,
There is some contradiction in the api documentation: on one location: https://developer.foursquare.com/docs/responses/user on another
There are several shading languages available today like GLSL, HLSL, CG, which one to

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.