I would like to know how to prototype a function that returns a array which also takes in an array. after prototyping the array how can i implement it
is this correct?
coffee* getData(*coffe);
int main() {
coffee cf[256];
coffee FinalCoffee[256];
FinalCoffee=getData(cf);
}
coffee getData(coffee objcf[]) {
for(int i=0;i<SIZE;i++) {
objcf[i].brand="nescafe";
}
return coffee;
}
Plsease do advice me on this. i need to be able to get back array so that i can pass the updated array to another function to process it.
Your code doesn’t even have matching declaration and function definition. This doesn’t work.
But the following does:
But if, as in your example, you want to manipulate the original array, rather than returning a new one, then it makes more sense to not have a return value at all, and to pass the argument as a non-const reference:
As a rule of thumb, try to avoid C arrays in favour of C++ standard library containers. This will make your life much, much easier.