/************************************************************************** GDB Test File 1 - contains several errors ***************************************************************************/ #include int readInArrayAndSum(int *array, int size) { int sum = 0; for ( int i = 1; i != size; i += 2 ) { cout << "\nEnter value [" << i << "] "; cin >> array[i]; sum += array[i]; } // for return sum; } // readInArrayAndSum /**************************************************************************/ int main() { int size; cout << "\nEnter the size of the array to sum [-D or -999 for EOF]:; for( ; ; ) { cin >> size; if ( cin.eof() ) break; if ( size == -999 ) break; if ( !cin.good() ) { cerr << "\nERROR: cannot have char or string for the array size\n"; exit(-2); } // if int *array; int returnValue = readInArrayAndSum(array, size); cout << "\nsum of ["; int i; for (i = 0; i < size-1; i += 1); { cout << array[i] << ", "; } // for cout << array[i] << "] is " << returnValue << endl; } // for return 0; } // main