Thread: pointer to enum type

  1. #1

    Question pointer to enum type

    Can I pass a enumerate type pointer to a function?
    I have never seen people pass enum type pointer to a function?
    why???? is it unsafe data by passing that way???

    enum Color {GREEN, YELLOW, RED};
    void main(void)
    enum Color colorVar = GREEN;


    void foo(enum Color *colorPtr)
    *colorPtr = RED;
    printf(" Traffic light now is RED");

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    >I have never seen people pass enum type pointer to a function?
    Probably because there was no need for them to do so.

    >is it unsafe data by passing that way???
    Not at all.

    >void main(void)
    This, however, is unsafe. Use int main ( void ) and return 0;.

    >void foo(enum Color *colorPtr)
    Don't forget to declare a prototype or place the function definition before main.

    And remember to include header files for the standard functions you intend to use, but I won't be too pedantic to you this time.

    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c program error
    By cutelucks in forum C Programming
    Replies: 14
    Last Post: 12-21-2007, 11:12 PM
  2. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  3. Compiler "Warnings"
    By Jeremy G in forum A Brief History of
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  4. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 06:17 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM