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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:35:22+00:00 2026-06-07T11:35:22+00:00

I have an issue passing a matrix to a function in C. There is

  • 0

I have an issue passing a matrix to a function in C. There is the function I want to create:

void ins (int *matrix, int row, int column);

but I noticed that in contrast to the vectors, matrix give me an error. How can I pass my matrix to a function so?

EDIT –> there is the code:

// Matrix

#include <stdio.h>
#define SIZE 100

void ins (int *matrix, int row, int column);
void print (int *matrix, int row, int column);

int main ()
{
    int mat[SIZE][SIZE];
    int row, col;

    printf("Input rows: ");
    scanf  ("%d", &row);
    printf("Input columns: ");
    scanf  ("%d", &col);

    printf ("Input data: \n");
    ins(mat, row, col);

    printf ("You entered: ");
    print(mat, row, col);

    return 0;
}

void ins (int *matrix, int row, int column);
{
    int i, j;

    for (i = 0; i < row; i++)
    {
        for (j = 0; j < column; j++)
        {
            printf ("Row %d column %d: ", i+1, j+1);
            scanf  ("%d", &matrix[i][j]);
        }
    }
}

void print (int *matrix, int row, int column)
{
    int i;
    int j;

    for(i=0; i<row; i++)
    {
        for(j=0; j<column; j++)
        {
            printf("%d ", matrix[i][j]);
        }
        printf("\n");
    }
}
  • 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-07T11:35:24+00:00Added an answer on June 7, 2026 at 11:35 am

    You need to pass a pointer with as much levels of indirection (*) as the number of dimensions of your matrix.

    For example, if your matrix is 2D (e.g. 10 by 100), then:

    void ins (int **matrix, int row, int column);
    

    If you have a fixed dimension (e.g. 100), you can also do:

    void ins (int (*matrix)[100], int row, int column);
    

    or in your case:

    void ins (int (*matrix)[SIZE], int row, int column);
    

    If both your dimensions are fixed:

    void ins (int matrix[10][100], int row, int column);
    

    or in your case:

    void ins (int matrix[SIZE][SIZE], int row, int column);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue right now with a program im trying to create. The
I have a function that I want to perform on all the types in
I have an issue passing a null value to NamedParameterJdbcTemplate using MapSqlParameterSource of the
I seem to have an issue passing the xml i am reading to a
I'm relatively new to C++, and having an issue passing a string. I have
I have an issue.. I am passing the image as the parameter to my
I have an issue with the following code. int main (int argc, const char
I have an odd issue with an NSDateFormatter, I am passing the following string
I have a issue with passing information from one wpf window to another. For
I have an issue with the submitted form information. Decimal parsing fails when 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.