# C - Convert array of elements into 2-d matrix It might be a stupid question, but I wonder if there is a efficient way to do this.

It might be a stupid question, but I wonder if there is a efficient way to do this.

The situation:

```int* array = malloc(n * m * sizeof(int));
//want to convert array into M[n][m]
```

what I am doing now:

```int** M = malloc(n * sizeof(int*));
for(int i = 0; i < n; i++, array += m)
M[i] = array;
```

I don't think the conversion should be this complex. Is there any simple syntax C provided? Can I declare an extern M[n][m] then set its address to the array?

(error handling and memory management in the sample is omitted for simplicity. Just think it as a part of some function.)

## C++ Arrays And Multidimensional Arrays

In this article we are going to talk about C++ Arrays And Multidimensional Arrays, so c++ arrays are collection of the elements that are the same type.

## C++ Arrays And Multidimensional Arrays

In this video we are going to talk about C++ Arrays And Multidimensional Arrays, so c++ arrays are collection of the elements that are the same type.

## Anonymous array in C#| Anonymous Collection | C# Bangla Tutorial | Advanced C#

ＬＩＫＥ | ＣＯＭＭＥＮＴ | ＳＨＡＲＥ | ＳＵＢＳＣＲＩＢＥ In this tutorial, I will discussed about Anonymous Array in C#. Blog : http://aspdotnetexplorer.blogspot.com Like our page...

## Count of triplets (a, b, c) in the Array such that a divides b and b divides c

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

## Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.