当前位置:网站首页>Creating dynamic two-dimensional array with C language

Creating dynamic two-dimensional array with C language

2022-06-10 23:22:00 Harris-H

C Language to create dynamic two-dimensional array

#include<bits/stdc++.h>
using namespace std;
int main(){
    
	int **a;
	a = (int**)malloc(sizeof(int*)*7); // Notice that this is   establish 7 individual int*  type  
	int i,j;
	for( i=0;i<7;i++){
    
		a[i] = (int*)malloc(sizeof(int)*5);
		for( j=0;j<5;j++)
			scanf("%d",&a[i][j]);
	}
	
	for( i=0;i<7;i++){
    
		for( j=0;j<5;j++){
    
			printf("%d ",a[i][j]);
		}
		puts("");
	} 
	return 0;
}
原网站

版权声明
本文为[Harris-H]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206102215497099.html