2012. 6. 8. 12:32

a.c , b.c 에서 변수 i를 공유할때


우선 a.h를 하나 만들고


a.c에

#include "a.h"

int i = 0;

선언


a.h에

extern int i;


b.c에

#include "a.h"


이로써 a.c에 있는 i변수를 b.c에서도 사용가능하며 a.c에서 변경해도 b.c에서 변경된 값으로 사용가능


'C' 카테고리의 다른 글

hex string 을 실제 hex값으로 변환하기  (0) 2012.04.16
include 여러 파일에서 할 때 중복선언 막기  (0) 2011.11.28
Posted by newkie
2012. 4. 16. 14:00

대충


macAddr[0] = "E"

macAddr[1] = "E"


sprintf(hexstr,"0x%c%c",macAddr[0],macAddr[1]);

Addr[0] = strtol(hexstr,err,16);


하면 Addr[0]에 0xEE!


EE!

'C' 카테고리의 다른 글

여러 c파일에서 전역변수 공유하기  (0) 2012.06.08
include 여러 파일에서 할 때 중복선언 막기  (0) 2011.11.28
Posted by newkie
2011. 11. 28. 10:19
C file

# define DUB_C

#include "xxx.h" 


Header file 

#ifdef EXTERN
 #undef EXTERN
#endif

#ifdef DUB_C
 #define EXTERN
#else
 #define EXTERN extern
#endif

EXTERN int a;
EXTERN char b;
EXTERN void c();
... 

'C' 카테고리의 다른 글

여러 c파일에서 전역변수 공유하기  (0) 2012.06.08
hex string 을 실제 hex값으로 변환하기  (0) 2012.04.16
Posted by newkie