functions and switch statement

This is a discussion on functions and switch statement within the C Programming forums, part of the General Programming Boards category; I have this program for class and I am almost done but I am stuck on this part. Basically, you ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    10

    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'
    ... etc.

    The program works fine until I throw in this larger enclosing function.

    Any ideas? Thanks in advance!

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,643
    Post the code.
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    Nevermind.
    Last edited by rmathus; 11-29-2003 at 06:32 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting the switch statement to work.
    By mtymightymike in forum C Programming
    Replies: 7
    Last Post: 10-15-2008, 06:32 PM
  2. Functions in a switch case...
    By yaya in forum C++ Programming
    Replies: 1
    Last Post: 04-30-2008, 03:58 AM
  3. Applying the Switch and some other functions.
    By kendo411 in forum C Programming
    Replies: 9
    Last Post: 01-20-2004, 08:55 AM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  5. switch statement / command line
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 12-20-2001, 03:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21