functions and switch statement
I have this program for class and I am almost done but I am stuck on this part. Basically, you have to write a program to print your name. You run the program and it makes a .gnuplot file and a .png file. Up until that point, I am fine.
The problem comes in when I try to ask the user to input what s/he wants printed to the screen, either first name, last name, or both names. I know to declare a variable for that, then put it into a switch statement and direct it to go to that segment of code (depending on which of the three options the user entered).
For example, I tried making a larger function of smaller functions, meaning I took my first name, Ryan, and had each of those letters in their own function. Then I made a function to enclose all of those letters into a larger function, functionFirstName, so I could call on it in the swtich statement. That way it would print out just the first name and stop there (assuming the user just wanted my first name printed). I'd also need to do the same for the last name, and for both first and last name so I would just use the same approach.
But this doesn't seem to work. Is it legal, or is there a better way to go about this?
The main errors I get for each function in the program are:
-warning: data definition has no type or storage class
-error: parse error before numeric constant
-error: conflicting types for `writeR'
-error: previous declaration of `writeR'
The program works fine until I throw in this larger enclosing function.
Any ideas? Thanks in advance!