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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:47:03+00:00 2026-06-04T23:47:03+00:00

I have a two dimensional array of ints which represents a few dots in

  • 0

I have a two dimensional array of ints which represents a few dots in a graph.

int16_t myPoints[][3] = {
  {0, 0},
  {20, 40},
  {14, 92}};

How can I pass a pointer to a function which will be able to read these coordinates?

something like?

void foo(int16_t *coordinates[][]) {
   drawPoint(x[0], y[0]);
   drawPoint(x[1], y[1]);
   ...

Thanks for the 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-04T23:47:05+00:00Added an answer on June 4, 2026 at 11:47 pm

    Only the first dimension can be unknown when declaring a function, so you have to declare/define the function like this:

    void foo(int16_t coordinates[][3])
    {
        drawPoint(coordinates[0][0], coordinates[1][0]);
        drawPoint(coordinates[0][1], coordinates[1][1]);
        drawPoint(coordinates[0][2], coordinates[1][2]);
    }
    

    Then you can call it like a normal function:

    foo(myPoints);
    

    Edit: Your array declaration is not correct, and I missed it too. It should be:

    int16_t myPoints[][2] = {
      /* List of points */
    };
    

    Now you have a proper coordinate-array, and it can be as long as you like.

    For the function to know the number of entries, you have to pass it to the function, so the new function declaration will be:

    void foo(int16_t coordinates[][2], int number_of_points);
    

    Don’t worry about copying, the compiler is smart enough to only pass the pointer to the array, so it will not copy the whole array.

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

Sidebar

Related Questions

I have a two dimensional array, which represents columns and rows of data. I
I have a two dimensional array of points, which constitute a map. The black
I have a output file which is a two dimensional array (this file was
If I have a two-dimensional array in C# - how can I convert it
I have a two-dimensional array (of Strings) which make up my data table (of
I have a two dimensional array, i.e. an array of sequences which are also
I have defined two dimensional array using following definition typedef std::vector<std::vector<short> > table_t; Can
I have a two-dimensional array of ints, for example: int [][] board= { {23,17,3,29,12,10},
I have a form in which i use two dimensional array for field names.The
I have a two-dimensional array. When I print/dump this I get the following My

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.