About 43,300 results
Open links in new tab
  1. Pass Array to Functions in C++ - GeeksforGeeks

    Jan 3, 2024 · Passing an array to a function allows the function to directly access and modify the original array. In this article, we will learn how to pass arrays to functions in C. In C, arrays are always passed to function as pointers.

  2. c++ - How to declare an array of functions? - Stack Overflow

    Aug 17, 2021 · Suppose I want to declare an array of functions, and try the following int (*funcs)(int, int)[10]; But turns out that the following declaration stands for an function returning an array, which does not compile.

  3. C++ Array of Functions - Stack Overflow

    int test1() { printf("hello\n"); return 0; } int test2() { printf("world\n"); return 1; } int main() { int n = -15; int (*(functions[2]))() = {test1, test2}; n = functions[0](); printf("%d\n", n); return 0; }

  4. How to define an array of functions in C - Stack Overflow

    Arrays in function parameters decay to pointers so your function is really void setFuncs(void(**funcsTo)(), void(**funcsFrom)()) with no information about the sizeof. You should a) use a macro, which would allow you to do that, or b) pass the array size as a third parameter.

  5. C++ Pass Array to a Function - W3Schools

    The function (myFunction) takes an array as its parameter (int myNumbers[5]), and loops through the array elements with the for loop. When the function is called inside main(), we pass along the myNumbers array, which outputs the array elements.

  6. How to Return a Local Array From a C++ Function?

    Dec 14, 2022 · Here, we will build a C++ program to return a local array from a function. And will come across the right way of returning an array from a function using 3 approaches i.e. Using Dynamically Allocated Array; Using Static Array ; Using Struct

  7. C++ Passing Arrays as Function Parameters (With Examples)

    In this tutorial, we will learn how to pass a single-dimensional and multidimensional array as a function parameter in C++ with the help of examples.

  8. How to pass an array to a function in C++ - Educative

    Dec 9, 2021 · Today, we’ll discuss how to pass arrays to functions in C++. Along the way, we’ll cover why we use C++ arrays, as well as how to declare and initialize them. We’ll then pass them to functions and discuss important distinctions about arrays in C++.

  9. Using Arrays With Functions In C++ - Software Testing Help

    Apr 1, 2025 · This tutorial on Arrays with Functions will explain how arrays can be used with functions in C++. Generally, arrays can be passed to functions as arguments in the same way as we pass variables to functions.

  10. c++ - Return array in a function - Stack Overflow

    Aug 13, 2010 · array< int, 5 > &fillarr( array< int, 5 > &arr ) { return arr; // "array" being boost::array or std::array } The array template simply generates a struct containing a C-style array, so you can apply object-oriented semantics yet retain the array's original simplicity.

  11. Some results have been removed
Refresh