From 4b1cbcc41c3ace0cf078e13220cb0466b29b593c Mon Sep 17 00:00:00 2001 From: Joe Traver Date: Wed, 26 Oct 2022 17:43:43 -0700 Subject: Made the Exercise 3 changes. Still problems with compiling --- CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp b/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp index 1e3d58b..8d9b7c8 100644 --- a/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp +++ b/CST116-Ch10-Debugging/CST116-Ch10-Debugging.cpp @@ -81,14 +81,14 @@ using std::setw; void GetAndDisplayWelcomeInfo(); void FunctionOne(int varX[], int varY[]); void FunctionTwo(const int varX[], const int varY[], int varZ[]); -void PrintFunction(const int varX[], const int varY[], - const int varZ[]); +void PrintFunction(const int varX[20], const int varY[20], + const int varZ[20]); -const int SIZE = 5; +const int SIZE = 10; int main() { - int varX[5]; + int varX[SIZE]; int varY[SIZE]; int varZ[SIZE]; // Notice how we used the const here! @@ -96,17 +96,22 @@ int main() // Put breakpoint on the following line GetAndDisplayWelcomeInfo(); FunctionOne(varX, varY); + // Breakpoint 3 // Put breakpoint on the following line FunctionTwo(varX, varY, varZ); + + varZ[0] = -99; + PrintFunction(varX, varY, varZ); return 0; } void GetAndDisplayWelcomeInfo() { - char name[2][20]; // First name in row 0, last name in row 1 + // First name in row 0, last name in row 1 + char name[2][20]{}; cout << "Please enter your first name: "; cin >> name[0]; @@ -126,14 +131,16 @@ void FunctionOne(int varX[], int varY[]) // Put breakpoint on the following line varX[x] = x; - for (int x = 0; x < 5; x++) + for (int x = 0; x < SIZE; x++) varY[x] = x + 100; } -void FunctionTwo(const int varX[], const int varY[], int varZ[]) +void FunctionTwo( int varX[], const int varY[], int varZ[]) { + varX[1] = 99; for (int x = 0; x < SIZE; x++) // Notice the const SIZE here varZ[x] = varX[x] + varY[x]; } + void PrintFunction(const int varX[20], const int varY[20], const int varZ[20]) { -- cgit v1.2.3