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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:40:17+00:00 2026-05-15T18:40:17+00:00

I have been trying to solve this problem the whole day: How do I

  • 0

I have been trying to solve this problem the whole day:

How do I pass a double array to a function?

Here is an example:

int matrix[5][2] = { {1,2}, {3,4}, {5,6}, {7,8}, {9,10} };

And I wish to pass this matrix to function named eval_matrix,

void eval_matrix(int ?) {
    ...
}

I can’t figure out what should be in place of ?

Can anyone help me with this problem?

I know that an array can be passed just as a pointer, but what about a double array (or triple array?)

Thanks, Boda Cydo.

  • 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-05-15T18:40:18+00:00Added an answer on May 15, 2026 at 6:40 pm

    To be usable as an array the compiler has to know the inner stride of the array, so it’s either:

    void eval_matrix( int m[5][2] ) { ...
    

    or:

    void eval_matrix( int m[][2], size_t od ) { ... /* od is the outer dimension */
    

    or just:

    void eval_matrix( int* p, size_t od, size_t id ) { ... /* ditto */
    

    In any case it’s syntactic sugar – the array is decayed to a pointer.

    In first two cases you can reference array elements as usual m[i][j], but will have to offset manually in the third case as p[i*id + j].

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

Sidebar

Related Questions

I have been trying to solve this problem for a while, but couldn't with
I have an interesting problem here I've been trying to solve for the last
I have been trying this for the whole day and I managed to make
I have been trying to solve this problem for a while, could not find
I have been trying to solve this strange problem with a website I am
I'm still a beginner and I have been trying to solve this problem by
I've been trying to solve this problem for a couple of hours but I
Background All day long I've been trying to solve a problem, I read all
I've been trying to solve this problem for a while now, and I'm at
I have been trying to solve this for a while. I am trying 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.