Suppose we have an array say:
int arr[1000];
and I have a function that works on that array say:
void Func(void);
Why would there ever be a need to pass by reference (by changing the void), when I can have arr[1000] as an external variable outside main()?
- What is the difference?Is there any difference?
- Why do people prefer passing by reference rather than making it external? (I myself think that making it external is easier).
I think you’re asking if global variables are bad. Quoting an excellent answer: