2008年10月31日 星期五

pragma pack

pragma pack(1):

#pragma pack()
回到預設值,在32-bit的系統上預設為pack(4)

2008年10月30日 星期四

little endian & big endian

how to know big endian or little endian?


#include

#ifdef __BYTE_ORDER
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define I_AM_LITTLE_ENDIAN
# else
# if __BYTE_ORDER == __BIG_ENDIAN
# define I_AM_BIG_ENDIAN
# else
Error: unknown byte order!
# endif
# endif
#endif /* __BYTE_ORDER */

uint64_t

include stdint.h

typedef signed char int8_t
typedef unsigned char uint8_t
typedef signed int int16_t
typedef unsigned int uint16_t
typedef signed long int int32_t
typedef unsigned long int uint32_t
typedef signed long long int int64_t
typedef unsigned long long int uint64_t

2008年9月11日 星期四

the website about c

http://www.cprogramming.com

coding book

Writing Secure Code

code complete 

2008年9月4日 星期四

static function

in c:
the scope of function is limited to the file

2008年7月29日 星期二

size for array & pointer

char str[100];
char *str2=str;
sizeof(str)  
--->   100
sizeof(str2)
---->  4