Quick actions

cmd+k|ctrl+k

Navigation

Languages

arrays++

Snippet info

Language

Cpp

Visibility

public

Author

danielmg17

Created

2018-02-05T19:18:36Z

Updated

2018-02-06T16:32:25Z

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

template<int N>
int * example(int (&x)[N]) {
    cout << x[1] << endl;//test
    for(int& i : x) {
        i += rand()%4;
    }
    return x;
}

int main() {
    srand((unsigned)time(NULL));
    int p[] = {1,2,3};
    int *tem = example(p);
    /*for(int& x : tem) {
        cout << x;
    }*/
    cout << *tem << *(tem+1) << *(tem+2) << *(tem+3) << endl;//test
    cout << tem[0] << tem[1] << tem[2] << tem[8] <<endl;
    cout << sizeof(tem)/sizeof(*tem);
    int ex[] = {1,2,3,4,5,6,7,8,9,10};
    cout << endl << sizeof(ex)/sizeof(*ex);
}
INFO