How to dynamically allocate a 2D array in C?

I know how to allocate 2D array but dynamically allocation is not clear. Would be thankful if someone will answer.

  • Aditi
  • 02 अप्रैल
  • 4324 दृश्य
  • 1 उत्तर
Your Answer

Following are different ways to create a 2D array on heap (or dynamically allocate a 2D array).
In the following examples, we have considered ‘r‘ as number of rows, ‘c‘ as number of columns and we created a 2D array with r = 3, c = 4 and following values

  1  2  3  4
  5  6  7  8
  9  10 11 12 

0
c programming
मॉक परीक्षण अभ्यास के लिए
c programming