So I finished up an assignment for school, but after speaking with my teacher about my assignment, he told me how my variables need to be passed through the function parameters for a number of reasons which I understand. However, I don't know where exactly to start to get each function and function call have the parameters of the variables I've already put in the code... Any tips to get started from having no parameters to having all of my code work with them? Would be greatly appreciated!
You could do it one step at a time. For example take the variable double percentage = 0;
Move it from the global scope and instead put it inside function main();
You can do a search in the code editor, to find where it is used. But equally, you could just compile the program, and check the error messages, that will tell you where it is used.
If the function needs to modify the value, pass it by reference, add it to the parameter list like this: void processData(double & percentage);
and where the variable is not to be modified, just pass it by value, like this: void outputData(double percentage);
In the case of the arrays you don't need to pass by reference, since an array is passed as a pointer. For example, this would be the declaration; void processData(double & percentage, char answerKey[]);
Of course, the function prototypes and the definitions must be kept synchronised. The function calls must also be modified accordingly, such as this, inside function main(), inputStudentData(percentage, answerKey);
Note that the examples I've quoted are not the finished code, as I suggested to work through the parameters one at a time.
One more thing, line 70 is inside a loop, I suspect it should be after the end of the loop. percentage = (answersCorrect / SIZE_OF_TEST) * 100;
You may find it beneficial to take a short time-out from working on the code and look at the tutorial, where it discusses passing parameters by reference or by value. http://www.cplusplus.com/doc/tutorial/functions2/
Agh okay, seems like the only error I have now is it's saying that
" undefined reference to `inputStudentData(char*, char*, std::string*, double, double)' "
I get the basics of parameters, just working backwards through a code that was working perfectly fine beforehand is challenging for a beginner. Well for me, anyways.
Glad you got it done. Actually, although you found this tricky, its a good skill to have, re-organising existing code can be useful - and if you need to do this in future, it will seem much easier.