Hi everyone i am new to the forums and was having a hard time with a homework assignment. I can't seem to understand how to use functions properly and figure out how to format what goes in "()" when calling them.
For this assignment we are supposed to create a structure to keep track of character statistics in an input file. I called this the "Counts" structure. Then we are supposed to prompt the user for an input file name. In this case it is a text file. Then another function is needed to determine what a character is and increase the appropriate counter. The characters are a combination of X's, Y's, Z's and some other characters that are referred to as "illegal". This is where we pass the Counts structure to the function. Then lastly we need a function to print the final report using a Counts structure passed to it.
What I am having trouble with is the "increase" function and its parameters. I'm sure there are other problems but for now this is what I am trying to deal with. Can anyone help me with this?
The first thing I notice here, is that your prototype and function definition do match in the parameters list. (i.e. you have (counts x, char ch) in the definition, but only an (x) with no data type in the prototype.)
What I mean here is that your prototype should always match your function definition in terms of the data type of your parameters.
For instance if I had this function:
At the moment, your increase function doesn't seem to be making use of anything in the Counts structure you're passing to it. When you write, for example:
numXs++;
you are incrementing the local variable
int numXs = 0;
that you declared at the start of your function.
Did you actually want to increment the member of your structure? If so, you access a structure member by putting the name of the structure object, a dot, and then the name of the member, like so: