Hi,
I'm trying to get the second call to SumNumbers a value other than 0. I think that the second call to SumNumber is 0 just like the first call because I have "static int cnt = 0;". I don't know how to change my program to get the second call to say 1. Here is my code:
Thanks!Code:#include <iostream> #include <fstream> using namespace std; int sum; void SumNumbers(); ifstream NumData; void main() {//block 1 SumNumbers(); cout << "Call 1: the sum of the numbers is " << sum << endl; SumNumbers(); cout << "Call 2: the sum of the numbers is " << sum << endl; } void SumNumbers() {//block 2 NumData.open("numbers.dat"); sum = 0; int num; static int cnt = 0; NumData >> num; while (cnt <=4) {//block 3 sum = sum + num; cnt++; } }