$0.09

C/C++: how to return an array from function

Ask a question+
1

How do I return an array from function?

int f(int arr[])
{
    /// do something with arr
    return arr;
}
Tigran 1.2K
add comment

1 Answer

0

You can use a pointer. The pointer is marked with * after the type name. Your code can be like this:

int* f(int arr[])
{
    /// do something with arr
    return arr;
}

You can see it. I add * after int in line.

Levi Rizki 170
add comment

Your Answer