10/26/05 CISC105 Lecture Notes We started last time with a file containing lines such as these: 0 2 1 1 0 4 2 6 0 1 These lines represent the number of goals scored by individual players, i.e. player 0, player 1, etc. up through player 9. We wrote a program, readData.c, that reads the data into an array. We then wrote some code to add up the total goals scored. Today we will make that code into a function. We'll then write functions to do other things, such as - finding the number of goals scored by the best player(s) - finding the player numbers of all players who scored that many goals. - finding the average number of goals scored per player. Then, we'll move on to a menu driven program that reads data from a file containing multiple values per line. Some important things to remember: (1) When breaking some code out of the main program into its own function, you want to look for which variables are NOT defined inside the part of the code you are breaking out. Those need to become your formal parameters. (2) When defining a formal parameter that is an array, you use an empty set of square brackets: int computeTotalGoalsScored( int count, int goalsPerPlayer[] ) ; It is also legal to put a number in the [] int computeTotalGoalsScored( int count, int goalsPerPlayer[10] ); but it is not needed, and it is often better, to leave the number out... because then the function can be used with any size of array. The following syntax is also equivalent, and is equally valid: int computeTotalGoalsScored( int count, int *goalsPerPlayer ); (3) You cannot "nest" function definitions...