Search
 
SCRIPT & CODE EXAMPLE
 

C

how to make a n*n 2d dynamic array in c++

int** a = new int*[rowCount];
for(int i = 0; i < rowCount; ++i)
    a[i] = new int[colCount];
Comment

declaring 2d dynamic array c++

int** arr = new int*[10]; // Number of Students
int i=0, j;
for (i; i<10; i++) 
	arr[i] = new int[5]; // Number of Courses
/*In line[1], you're creating an array which can store the addresses
  of 10 arrays. In line[4], you're allocating memories for the 
  array addresses you've stored in the array 'arr'. So it comes out 
  to be a 10 x 5 array. */
Comment

function for 2d dynamic array

int ** two_dim_array(int row_num, int col_num)
{
	int **two_dim_array=(int **)malloc(sizeof(int *)*row_num);
    int i, j;
  	for(i=0:i<row_num;i++)
    {
  		two_dim_array[i]=(int *)malloc(sizeof(int)*col_num);
      	for(j=0:j<col_num;j++)
          	two_dim_array[i][j]=0;
    }
  	return two_dim_array;
}
Comment

PREVIOUS NEXT
Code Example
C :: linked list in c 
C :: what is implicit typecasting 
C :: difference between int main() and int main(void) 
C :: i2c scanner 
C :: how to find the elements in array c coding 
C :: calendar in c 
C :: c check if is a right triangle 
C :: install zoom on ubuntu 
Dart :: flutter rounded bottom sheet 
Dart :: flutter elevated button radius 
Dart :: copy to clipboard flutter 
Dart :: flutter appbar text color 
Dart :: dart input field overflow when keyboard open 
Dart :: order list dart 
Dart :: type check of variable dart 
Dart :: dart timer delay 
Dart :: flutter cliprrect 
Dart :: How do you add a label (title text) to a Checkbox in Flutter? 
Dart :: flutter lock orientation for page 
Dart :: text should come below if space not available row flutter 
Dart :: flutter screen size 
Dart :: create publisher account on pub.dev 
Dart :: How to make checkbox shape to circular using flutter 
Dart :: how to give bottom padding in Listview in flutter 
Dart :: pass function as parameter in flutter 
Dart :: declaring and initializing a list in dart 
Dart :: how to add cards in flutter 
Dart :: datetimeoffset flutter 
Dart :: alertdialog shape flutter 
Dart :: app bar textStyle flutter 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =