gpt4 book ai didi

c++ - 在 C++ 中创建大小为 1000000000 的数组给了我以下错误。请帮助我理解并解决它

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:50:35 24 4
gpt4 key购买 nike

<分区>

我需要创建一个大小为 1000000000 的数组。

#include<iostream>
#include<cstdlib>
#include<math.h>
#include<cmath>
using namespace std;
unsigned long long int arr[1000000000];
int ZofF(long long int n)
{
for(unsigned long long int i=1;i<=1000000000;i++)
{
}
}
int main()
{
return 0;
}

我收到这样的错误:

C:\Users\TARUNM~1\AppData\Local\Temp\cccgeKSu.s Assembler messages: 63 C:\Users\TARUNM~1\AppData\Local\Temp\cccgeKSu.s Error: value of 00000001dcd6504e too large for field of 4 bytes at 000000000000004e 87 C:\Users\TARUNM~1\AppData\Local\Temp\cccgeKSu.s Error: value of 00000001dcd6507e too large for field of 4 bytes at 000000000000007e


有一个解决方案: How to handle an array with size 1,000,000,000 in C++?

我试过将它分成多个数组,我实际上并没有从上面的链接中理解解决方案。这是代码:

    #include<iostream>
#include<cstdlib>
#include<math.h>
#include<cmath>
using namespace std;
unsigned long int arr[125000000];
unsigned long int ar2[125000000];
unsigned long int ar3[125000000];
unsigned long int ar4[125000000];
unsigned long int ar5[125000000];
unsigned long int ar6[125000000];
unsigned long int ar7[125000000];
unsigned long int ar8[125000000];
int ZofF(long long int n)
{
for(unsigned long long int i=1;i<=250000000;i++)
{
}
}
int main()
{
return 0;
}

但是这段代码给了我以下错误。

c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\lib\crt2.o In function check_managed_app':
357 h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol
mingw_initltsdrot_force'

defined in .bss section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-tlssup.o) 358
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `mingw_initltsdyn_force'

defined in .bss section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-tlssup.o) 359
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `mingw_initltssuo_force'

defined in .bss section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-tlssup.o) 360
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x3f): relocation truncated to fit: R_X86_64_PC32 against symbol `mingw_initcharmax' defined in

.bss section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-charmax.o) c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\lib\crt2.o In function pre_c_init':
129<br/>
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x51): relocation truncated to fit: R_X86_64_PC32 against symbol
mingw_app_type' defined in

.bss section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-mingw_helpers.o) 135
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `_fmode' defined in .bss

section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-xtxtmode.o) 133
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `__onexitend' defined in COMMON

section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-atonexit.o) 133
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x7f): relocation truncated to fit: R_X86_64_PC32 against symbol `__onexitbegin' defined in

COMMON section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-atonexit.o) 135
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x86): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp__fmode' defined in

.idata$5 section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmsvcrt.a(dqows00253.o) c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\lib\crt2.o In function pre_cpp_init':
157<br/>
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x136): relocation truncated to fit: R_X86_64_PC32 against symbol
_newmode' defined in .bss

section in C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib/libmingw32.a(lib64_libmingw32_a-_newmode.o) 162
h:\crossdev\src\mingw-w64-v3-svn\mingw-w64-crt\crt\crtexe.c (.text+0x13d): additional relocation overflows omitted from the output [Error] ld returned 1 exit status

请帮助我理解为什么会发生这种情况以及如何创建大小为 1000000000 的数组。我在 i5 内核和 4Gb RAM 上使用 64 位 Windows 8.1。我必须升级我的硬件吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com