Mega Code Archive

 
Categories / C++ Tutorial / Function
 

Declare int array parameter for a function without indicating the array length

#include <iostream>  using namespace std;    void display(int num[]);    int main()  {    int t[10], i;      for(i=0; i < 10; ++i) t[i]=i;      display(t); // pass array t to a function      return 0;  }    void display(int num[])  {    int i;      for(i=0; i < 10; i++) cout << num[i] << ' ';  } 0 1 2 3 4 5 6 7 8 9