I'm having a lot of trouble figuring out how to pass values back and forth between functions.
In the program I'm working on now, I'm supposed to declare an integer array (n) and an integer (count) in main, then pass those to a function which opens a txt file and then starts a loop. The loop takes the values in the txt file and stores them in n, while count keeps track of how many times the loop runs. At the end the function should pass n and count back to main, then main prints the results. That's where I'm having trouble.
Here's a sample of my code:
For some reason n makes it through and displays the correct number, but count always shows up as 0. Can anyone explain what I'm doing wrong?
using namespace std;
int ReadFile(int n, int count);
int count = 0;
cout << "There are " << count << " numbers in the file.\n";
cout << "The first number is " << n << endl;
int ReadFile(int n, int count)
cout << "Cannot open file" << endl;
input >> n[count];
return n, count;