Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > how to create an array for 15000 integers?

Reply
Thread Tools

how to create an array for 15000 integers?

 
 
David
Guest
Posts: n/a
 
      12-13-2006
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"

 
Reply With Quote
 
 
 
 
wahaha
Guest
Posts: n/a
 
      12-13-2006
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 д
"
> 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"


 
Reply With Quote
 
 
 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      12-13-2006
wahaha <(E-Mail Removed)> wrote:

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


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

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

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


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.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      12-13-2006
"wahaha" <(E-Mail Removed)> writes:
> 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 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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.
 
Reply With Quote
 
Bill Reid
Guest
Posts: n/a
 
      12-14-2006

David <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...

> 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"
>

Maybe try declaring it as a global array? Move it out of a
function body and see what happens...

---
William Ernest Reid



 
Reply With Quote
 
David T. Ashley
Guest
Posts: n/a
 
      12-14-2006
"David" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>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"


Make it static or global.

Or, dynamically allocate it.

With a typical compiler, local variables are stored in what is called a
"stack frame".

http://en.wikipedia.org/wiki/Call_stack

Typically, there are at least a couple of reasons why the size of the stack
and each individual stack frame is limited. The most pressing reason is
often that to retrieve and store values to the stack frame, machine
instructions that are stack-relative are used. These instructions typically
embed a stack-pointer relative offset into the instruction, and the
instruction encoding imposes a limit on how big the offsets can be.
Somewhere around 4,000 bytes (11 or 12 bits) strikes me as typical for a
desktop machine. 15,000 integers is quite a large array.

Most programmers think twice when something of storage class automatic that
has more than a couple dozen elements.



 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      12-14-2006
David wrote:
> 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"
>


You are using Miracl C, what is a DOS C ompiler. Under DOS you just
can't do anything big like that, and specially the stack is a precious
ressource to be used with utmost care.

You have two possibilities:
1) Go on use an obsolete compiler/OS and spend a lot of time
programming around its limitations; This *could* have been
OK in 1990, it is quite senseless now

2) Use a 32 bit OS for your programming: Linux/windows, whatever.

 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      12-14-2006
jacob navia <(E-Mail Removed)> wrote:

> David wrote:
> > 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".

>
> You are using Miracl C, what is a DOS C ompiler.


_Which_ is a DOS compiler.

> Under DOS you just can't do anything big like that,


Bullshit. Under Miracle C you may not be able to do that, but that
doesn't mean that there aren't any C implementations that do let you use
this array. In fact, I'd be surprised if the one I used to use didn't.

> 1) Go on use an obsolete compiler/OS and spend a lot of time
> programming around its limitations; This *could* have been
> OK in 1990, it is quite senseless now


Tell that to the MS-DOS program that's still running the back-end of our
A2 full-colour scanner.

Richard
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      12-14-2006
Richard Bos wrote:
> jacob navia <(E-Mail Removed)> wrote:
>
>
>>David wrote:
>>
>>>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".

>>
>>You are using Miracl C, what is a DOS C ompiler.

>
>
> _Which_ is a DOS compiler.


Gosh I can't get that right...

Thanks

>
>
>>Under DOS you just can't do anything big like that,

>
>
> Bullshit. Under Miracle C you may not be able to do that, but that
> doesn't mean that there aren't any C implementations that do let you use
> this array. In fact, I'd be surprised if the one I used to use didn't.
>
>
>>1) Go on use an obsolete compiler/OS and spend a lot of time
>> programming around its limitations; This *could* have been
>> OK in 1990, it is quite senseless now

>
>
> Tell that to the MS-DOS program that's still running the back-end of our
> A2 full-colour scanner.


USING MS-DOS programs, and even developing embedded software in MSDOS
is OK. But LEARNING C with MSDOS?
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-14-2006
jacob navia said:

<snip>

> USING MS-DOS programs, and even developing embedded software in MSDOS
> is OK. But LEARNING C with MSDOS?


Sure, why not?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Please help! Why am I gettting 15000 emails???? gaiami1@tds.net Computer Support 6 12-04-2006 10:37 PM
a digicam for $300/Rs.15000 vivek Digital Photography 0 06-06-2006 05:18 AM
!!!TURN 5$ INTO 15000$!ITS SIMPLE!!100% LEGAL!ENJOY!! JT Digital Photography 0 02-23-2006 12:44 AM
15000 foot home KT Wireless Networking 10 12-17-2004 07:42 AM



Advertisments