how do I init an array? don't know how to init an array

I’m a beginner at cuda and have a faily basic quesition :">
I want to define an array in a seperate function which is later used in another function. The function defining the array will only be used once. the other function will be called in a loop over and over again.
Preferably I would like a third function wich free the memory of the array when I close my application.
The cuda functions are called by my application made in c++.
How do I do this? Help!