如何为15000个整数创建一个数组? [英] how to create an array for 15000 integers?

查看:97
本文介绍了如何为15000个整数创建一个数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做一个大约15000个整数的数组。

我已经将它声明为无符号字母[13000];

但是编译器说这个太多了。

如何为15000个整数创建数组?


我正在使用Miracle C编译器。


这是我收到的错误:


" c:\documents and settings\david\desktop\asdasdasdasdasdasdasdad22.c:

第6行:太多当地人宣布

''未签名的信[15000]''

中止编译"

I need to do an array with around 15000 integers in it.
I have declared it as unsigned letter[13000];
But the compiler is saying that this is too much.
How can I create an array for 15000 integers?

I am using "Miracle C compiler".

This is the error i am recieving:

"c:\documents and settings\david\desktop\asdasdasdasdasdasdasdad22.c :
line 6: too many locals declared
''unsigned letter[15000]''
aborting compile"

推荐答案

这取决于您的桌面有多少内存。假设你有足够的内存,你可以写:


unsigned int * letter;

if((letter = malloc( 15000 * sizeof(int)))== NULL)

返回-1;

" David D'μà£o

"
This will depend on how many memory your desktop has. Assume you have
enough memory, you can write:

unsigned int *letter;
if ((letter = malloc(15000 *sizeof(int))) == NULL)
return -1;
"David D′μà£o
"

我需要做一个大约有15000个整数的数组。

我已经将它声明为无符号字母[13000];

但编译器说这太多了。

如何为15000个整数创建一个数组?


我正在使用Miracle C编译器。


这是我收到的错误:


" c:\documents and settings \ david\desktop\asdasdasdasdasdasdasdad22.c:

第6行:太多当地人宣布

''未签名的信[15000]''

中止编译
I need to do an array with around 15000 integers in it.
I have declared it as unsigned letter[13000];
But the compiler is saying that this is too much.
How can I create an array for 15000 integers?

I am using "Miracle C compiler".

This is the error i am recieving:

"c:\documents and settings\david\desktop\asdasdasdasdasdasdasdad22.c :
line 6: too many locals declared
''unsigned letter[15000]''
aborting compile"


wahaha< zh *********** @ gmail.comwrote:
wahaha <zh***********@gmail.comwrote:

这取决于您的桌面有多少内存。假设你有足够的内存,你可以写:
This will depend on how many memory your desktop has. Assume you have
enough memory, you can write:



A.现在你知道。

Q.为什么顶级帖子不好?

A. Now you know.
Q. Why is top-posting bad?


unsigned int * letter;

if((letter = malloc(15000 * sizeof(int)) )== NULL)
unsigned int *letter;
if ((letter = malloc(15000 *sizeof(int))) == NULL)



if((letter = malloc(15000 * sizeof(* letter)))== NULL)

if( (letter=malloc(15000*sizeof(*letter))) == NULL )


返回-1;
return -1;



不是我错误处理的首选。


-

C. Benson Manica |我*应该*知道我在说什么 - 如果我

cbmanica(at)gmail.com |不,我需要知道。火焰欢迎。

Not my first choice for error handling.

--
C. Benson Manica | I *should* know what I''m talking about - if I
cbmanica(at)gmail.com | don''t, I need to know. Flames welcome.


" wahaha" < zh *********** @ gmail.comwrites:
"wahaha" <zh***********@gmail.comwrites:

这取决于您的桌面有多少内存。假设你有足够的内存,你可以写:


unsigned int * letter;

if((letter = malloc( 15000 * sizeof(int)))== NULL)

返回-1;
This will depend on how many memory your desktop has. Assume you have
enough memory, you can write:

unsigned int *letter;
if ((letter = malloc(15000 *sizeof(int))) == NULL)
return -1;



letter是指向unsigned int的指针,但是你使用sizeof(int)。是的,

他们保证是相同的,但是没有必要依赖

。事实上,写作的首选方式是:


if((letter = malloc(15000 * sizeof * letter))== NULL)


什么是return -1应该完成?只有当代码在一个返回某个整数(或

最少算术)类型的函数中时才有意义

。如果你假设代码在main(),

之后,那么(a)这是一个不好的假设,(b)从main()返回-1是

不便携。


请不要顶尖。请参阅以下内容:

http://www.caliburn。 nl / topposting.html
http ://www.cpax.org.uk/prg/writings/topposting.php


-

Keith Thompson(The_Other_Keith)< a href =mailto:ks *** @ mib.org> ks *** @ mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *< http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。

letter is a pointer to unsigned int, but you use sizeof(int). Yes,
they''re guaranteed to be the same, but there''s no point in depending
on that. In fact, the preferred way to write that is:

if ((letter = malloc(15000 * sizeof *letter)) == NULL)

And what is the "return -1" supposed to accomplish? That makes sense
only if the code is in a function that returns some integer (or at
least arithmetic) type. If you''re assuming the code is within main(),
then (a) that''s a bad assumption, and (b) returning -1 from main() is
not portable.

And please don''t top-post. See the following:

http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


这篇关于如何为15000个整数创建一个数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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