Thread: Functions are killing me

  1. #1
    Registered User mike's Avatar
    Join Date
    Aug 2001

    Functions are killing me

    Hi can someone please look at this and tell how i can use a switch statement called print to work with my program. I think my problem is in the functions. all the functions work as the program is now but when i make a function called print and use a switch statement then i have problems. im still trying to learn to pass by value and its messing me up. hope you can help thanks!

  2. #2
    Registered User
    Join Date
    Mar 2002
    Hello Mike,
    I hope that the text file I downloaded is corrupt, and not identical to your source code. This can't be working, The <do> loop and the <switch> statement in the main function is not matched. The showMenu function does not return anything. Please check out the code and try again.
    But just a guess: can it just be that the name <print> is already taken?

  3. #3
    Pointers seem to be the biggest thing everyone has problems with-- think of it this way--

    Passing by Value= contents of variable
    Passing by Reference = address of variable

    void foo1(char);                           /* prototypes */
    void foo2(char*);
    int main(void);
    int main(void)
       char  myLetter;
       myLetter = 'X';
       foo1(myLetter);                        /* pass by value (contents of 'myLetter') */
       foo2(&myLetter);                      /* pass by reference (refer to contents by passing address of 'myLetter') */
    void foo1(char letter)
       if(letter == 'X')                           /* look at value of 'letter' */
    void foo2(char *letter)
       if(*letter == 'X')                        /* go through 'letter' which is address of original variable to get to contents */


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  2. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  3. functions are killing me
    By 77walker in forum C++ Programming
    Replies: 4
    Last Post: 11-13-2004, 03:49 PM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM