wrote:
> I want to return an array from a function and catch it in an an array
> variable.
>
> For example like this
>
> int main(){
> int a[3];
> a = get_value();
> return 0;
> }
>
> int[] get_value(){
> int b[3]={0,1,2};
> return b;
> }
>
>
> This is a bit like Java. How to get this thing done in C.
C is not Java, and one of the differences (there are
many) is in the way arrays are implemented. It is sometimes
said that arrays are not "first-class citizens" in C, mostly
because there are only two operators that work on entire
arrays: the `sizeof' operator and the `&' address-of operator.
In particular, the `=' assignment operator doesn't work on
arrays, so your attempt at `a = get_value()' is doomed from
the start.
What to do instead? Well, it depends on what you want
to accomplish. Take a step back, realize that you're not
writing Java, and don't let the syntactic similarity of C
and Java sucker you into trying to use Java techniques in a
C program. "Gift" is a perfectly good noun in both English
and German (closely-related languages), but while you might
give one to a friend you would not give it to a Freund.
So: What's the larger problem you're trying to solve?
--
Eric Sosman
lid