Answer the question
In order to leave comments, you need to log in
How to pass a one-dimensional array from one function to another?
Good afternoon! How to pass a one-dimensional array from one function to another? I have an array forming function and an array printing function. How do I pass an array from one to the other in order to print it?
Answer the question
In order to leave comments, you need to log in
If this is C++, then use std::vector. One function creates and returns it, another prints it.
To avoid unnecessary copying, pass as a constant reference:
std::vector<int> MakeArray();
void Print(const std::vector<int> array);
int* MakeArray(int *len);
void Print(int *array, int len);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question