0

Possible Duplicate:
howto return a array in a c++ method?

How can an array be returned from a function? I'm going for an effect like this:

int getArray()
{
    return {1, 2, 3, 4, 5};
}

...

int myArray[5] = getArray();

1

1 Answer 1

0

Either dynamic allocation or std::vector. You can't return an array by value.

Sign up to request clarification or add additional context in comments.

2 Comments

Then how do things like myString.c_str work?
c_str() doesn't return array, it returns a pointer (to an internal buffer)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.