当前位置:网站首页>[c语言]二维数组动态分配内存
[c语言]二维数组动态分配内存
2022-07-30 19:53:00 【r77683962】
#include <stdio.h>
#include <stdlib.h>
int main()
{
int **p = 0;
p = (int **)malloc(10 * sizeof(int *));
if (NULL == p)
{
printf("malloc error");
return 0;
}
for(int i=0;i<10;i++)
{
p[i] = (int *)malloc(10 * sizeof(int *));
if (NULL == p[i])
{
printf("malloc2 error");
return 0;
}
}
for(int i=0;i< 10;i++)
{
for(int j=0;j< 10;j++)
{
p[i][j] = i * 10 + j;
printf("%d ", p[i][j]);
}
printf("\n");
}
}
边栏推荐
- Interviewer Ali: Describe to me the phenomenon of cache breakdown, and talk about your solution?
- 技术很牛逼,还需要“向上管理”吗?
- Cesium loads offline maps and offline terrain
- MindSpore:npu 多卡训练自定义数据集如何给不同npu传递不同数据
- OSS简单上传图片
- halcon——轮廓线
- 阿里面试这些微服务还不会?那还是别去了,基本等通知
- MySQL分组后取最大一条数据【最优解】
- Snowflake vs. Redshift的2022战报:两个数据平台谁更适合你?
- MySQL复制表结构、表数据的方法
猜你喜欢
随机推荐
DCM 中间件家族迎来新成员
[hbuilder] cannot run some projects, open the terminal and cannot enter commands
【PyTorchVideo教程01】快速实现视频动作识别
MindSpore:ImageFolderDataset数据读取问题
KEIL问题:【keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘】
MySQL slow query optimization
055 c# print
推荐系统:冷启动问题【用户冷启动、物品冷启动、系统冷启动】
Linux下安装MySQL教程
Trial writing C language sanbang
推荐系统-排序层-模型(一):Embedding + MLP(多层感知机)模型【Deep Crossing模型:经典的Embedding+MLP模型结构】
Cesium loads offline maps and offline terrain
MySQL六脉神剑,SQL通关大总结
Database indexes: indexes are not a panacea
Maxwell 一款简单易上手的实时抓取Mysql数据的软件
JUnit 5测试中的临时目录(附实例及代码)
MySQL分组后取最大一条数据【最优解】
Day31 LeetCode
Snowflake vs. Redshift的2022战报:两个数据平台谁更适合你?
Install Mysql5.7 under Linux, super detailed and complete tutorial, and cloud mysql connection








