Sign in

username:

password:



Not a member?

Search rabbit-semi



Search tips

Subscribe to rabbit-semi



Ads

Discussion Groups

Discussion Groups | Rabbit-Semi | Create array with size from function parameter

This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. Rabbit Semi is a spin-off from Z-World who makes a variety of embedded modules and tools. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions, flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.

Create array with size from function parameter - Jonathan Loechel - Jul 28 10:03:19 2008

Hi,
Im doing a project with a Rabbit 3000 at Uni and I'm having trouble trying to create an array of integers.
This is basically what im trying to do.
void FunctionName(param1, param2, int arraySize){
    int tempArray[arraySize];
    ......
    .....
    .....
}
The compiler bombs on the array declaration line and says that it expects a constant value.
Is there anyway around this problem.
Thanks, Jonathan.
Find a better answer, faster with the new Yahoo!7 Search. www.yahoo7.com.au/search


(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )


Re: Create array with size from function parameter - Steve Trigero - Jul 28 10:18:44 2008

You can't do what you want, the compiler needs to know the size of
the array at compile time. If you want to have dynamically allocated
memory, use the xalloc() function.

----- Original Message ----
From: Jonathan Loechel
To: r...@yahoogroups.com
Sent: Monday, July 28, 2008 12:02:12 AM
Subject: [rabbit-semi] Create array with size from function parameter
Hi,

Im doing a project with a Rabbit 3000 at Uni and I'm having trouble trying to create an array of integers.

This is basically what im trying to do.

void FunctionName( param1, param2, int arraySize){

int tempArray[arraySize ];
......
.....
.....

}

The compiler bombs on the array declaration line and says that it expects a constant value.

Is there anyway around this problem.

Thanks, Jonathan.
________________________________
Find a better answer, faster with the new Yahoo!7 Search - Start Here.


(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )