错误1错误C2148:数组的总大小不得超过0x7fffffff字节我在C中得到此错误 [英] Error 1 error C2148: total size of array must not exceed 0x7fffffff bytes I get this Error in C

查看:380
本文介绍了错误1错误C2148:数组的总大小不得超过0x7fffffff字节我在C中得到此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个 char [1 048 576] [16 384] [1024] 和一个 int [1 048 576] [16 384] ,但出现错误!

I want to make a char[1 048 576][16 384][1024] and a int [1 048 576][16 384] but I get an Error!

我想制作一个3d数组,与excel一样大!

I want to make an 3d array as big as excel can handle!

推荐答案

要在C中创建数组,您需要使用malloc静态或动态分配一些内存。
在任何情况下,阵列都将物理映射到您的计算机中,就像在RAM中一样。因此,您需要有足够的物理空间来制作它。

to "make" an array in C you need to allocate some memory, either statically or dynamically with malloc. In any case, the array will be mapped physically in your computer like in the RAM. So you need to have enough physical place to "make" it.

在您的情况下,您需要一个大小为char的字符数组:
1048576 * 16384 * 1024 * sizeof(char)= 1048576 * 16384 MB,char大小为1个字节。

In your case, you want a char array of size: 1048576*16384*1024*sizeof(char) = 1048576*16384 MByte with char size is 1 byte.


您得到的错误与此有关。
它告诉您可以请求的最大大小是有符号整数的最大数目。
请参阅: int32的最大值是多少?
就是要分配的值。

That is just too much. The error you get is related to that. It tells you that the maximum size you can request is the max number for a signed integer. See: What is the maximum value for an int32?. which is way under what you want to allocate.

如果您查看excel,则所有单元格都是空的,直到为它们保留了内存填充。

If you look at excel, the cells are all empty and no memory is reserved for them until they are filled.

这篇关于错误1错误C2148:数组的总大小不得超过0x7fffffff字节我在C中得到此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆