Thread: Somebody please helps me!

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    16

    Somebody please helps me!

    When I include my enumeration in same project but two files, it failed. Could you tell me what is wrong?

    Like these:

    Code:
    /*TheEnum.h*/
    enum TheEnum{
    	TheEnum_True,
    	TheEnum_False
    }
    Code:
    /*main.c*/
    #include "TheEnum.h"
    #include "Show_TheEnum.h"
    
    int main(void){
    	enum TheEnum GoodWeather = TheEnum_True;
    
    	Show_TheEnum(GoodWeather);
    
    	return 0;
    }
    Code:
    /*Show_TheEnum.h*/
    #include <stdio.h>
    #include "TheEnum.h"
    
    void Show_TheEnum(enum TheEnum);
    Code:
    /*Show_TheEnum.c*/
    void Show_TheEnum(enum TheEnum It){
    	switch(It){
    		case TheEnum_True:
    			puts("True");
    			break;
    		case TheEnum_False:
    			puts("False");
    			break;
    		default:
    			break;
    
    	return;
    }

  2. #2
    Nasal Demon Xupicor's Avatar
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    179
    Code:
    /*TheEnum.h*/
    enum TheEnum{
    	TheEnum_True,
    	TheEnum_False
    };
    Oh, and you should use include guard, you know.

    edit - like that:

    Code:
    #ifndef MYSOMETHING_H
    #define	MYSOMETHING_H
    
    //my includes and code
    
    #endif	/* MYSOMETHING_H */

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    16
    Get it. Thanks, Xupicor.

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Normally, enums start with 0, so is there a reason true is zero and false is nonzero? That could be confusing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Helps with strings
    By 3wit in forum C Programming
    Replies: 3
    Last Post: 05-01-2008, 07:58 AM
  2. Replies: 4
    Last Post: 02-21-2006, 06:33 PM
  3. CDC shape Helps
    By cfrost in forum C++ Programming
    Replies: 3
    Last Post: 05-13-2004, 05:49 AM
  4. Here's a problem, any one helps me?
    By NightWalker in forum C Programming
    Replies: 19
    Last Post: 06-10-2003, 09:19 AM
  5. Again TreeView and Node,any expert programmer helps me....?
    By AsAdi in forum Windows Programming
    Replies: 0
    Last Post: 02-24-2003, 03:42 AM