Somebody please helps me!

This is a discussion on Somebody please helps me! within the C Programming forums, part of the General Programming Boards category; When I include my enumeration in same project but two files, it failed. Could you tell me what is wrong? ...

  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
    a guy with long hair Xupicor's Avatar
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    103
    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 */
    Last edited by Xupicor; 09-23-2010 at 08:33 PM.

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

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,673
    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, 05: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, 02:42 AM

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