C struct ÖÐ×Ö½Ú¶ÔÆëÎÊÌâ
VCÖÐÏÂÃ漸¸ö½á¹¹Ìå´óС·Ö±ðÊǶàÉÙÄØ
struct MyStruct
{
double m4;
char m1;
int m3£»
};
struct MyStruct {
char m1;
double m4;
int m3;
};
#pragma pack(push)//±£´æ¶ÔÆë״̬
#pragma pack(16) //ÉèÖÃΪ16×Ö½Ú¶ÔÆë
struct test
{
char m1;
int m3;
double m4;
};
#pragma pack(pop)//»Ö¸´¶ÔÆë״̬
Èç¹ûÄãµÄ´ð°¸²»ÊÇ16£¬24ºÍ16£¬ÏàÐÅÏÂÃæµÄÄÚÈݶÔÄãºÜÓаïÖú¡£
1¡¢ sizeofÓ¦ÓÃÔڽṹÉϵÄÇé¿ö
Çë¿´ÏÂÃæµÄ½á¹¹£º
struct MyStruct
{
double dda1;
char dda;
int type
};
¶Ô½á¹¹MyStruct²ÉÓÃsizeof»á³öÏÖʲô½á¹ûÄØ£¿sizeof(MyStruct)Ϊ¶àÉÙÄØ£¿Ò²ÐíÄã
»áÕâÑùÇó£º
sizeof(MyStruct)=sizeof(double)+sizeof(char)+sizeof(int)=13
µ«Êǵ±ÔÚVCÖвâÊÔÉÏÃæ½á¹¹µÄ´óСʱ£¬Äã»á·¢ÏÖsizeof(MyStruct)Ϊ16¡£ÄãÖªµÀΪʲ
ôÔÚVCÖлáµÃ³öÕâÑùÒ»¸ö½á¹ûÂð£¿
Æäʵ£¬ÕâÊÇVC¶Ô±äÁ¿´æ´¢µÄÒ»¸öÌØÊâ´¦Àí¡£ÎªÁËÌá¸ßCPUµÄ´æ´¢Ëٶȣ¬VC¶ÔһЩ±äÁ¿µÄ
ÆðʼµØÖ·×öÁË“¶ÔÆë”´¦Àí¡£ÔÚĬÈÏÇé¿öÏ£¬VC¹æ¶¨¸÷³ÉÔ±±äÁ¿´æ·ÅµÄÆðʼµØÖ·Ïà¶ÔÓÚ½á
¹¹µÄÆðʼµØÖ·µÄÆ«ÒÆÁ¿±ØÐëΪ¸Ã±äÁ¿µÄÀàÐÍËùÕ¼ÓõÄ×Ö½ÚÊýµÄ±¶Êý¡£ÏÂÃæÁгö³£ÓÃÀàÐ͵Ä
¶ÔÆ뷽ʽ(vc6.0,32λϵͳ)¡£
ÀàÐÍ ¶ÔÆ뷽ʽ£¨±äÁ¿´æ·ÅµÄÆðʼµØÖ·Ïà¶ÔÓڽṹµÄÆðʼµØÖ·µÄÆ«ÒÆÁ¿£©
Char Æ«ÒÆÁ¿±ØÐëΪsizeof(char)¼
Ïà¹ØÎĵµ£º
1.ÒýÑÔ
¡¡¡¡C++ÓïÑԵĴ´½¨³õÖÔÊÇ¡°a better C¡±£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++ÖÐÀàËÆCÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëCÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC¼æÈݵÄÓïÑÔ£¬C++±£ÁôÁËÒ»²¿·Ö¹ý³ÌʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ¡°²»³¹µ×µØÃæÏò¶ÔÏó¡±£©£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö±äÁ¿ºÍº¯Êý¡£µ«ÊÇ£¬C++±Ï¾¹ÊÇÒ»ÖÖÃæÏò¶ ......
ÏÈÓñ´¶ûµÄÒ»µÀ±ÊÊÔÌâ¼òÒªµÄ˵Ã÷һϰɣº
¡¾Ì⡿˵Ã÷ÒÔϳÌÐò¡£
#include
int main(void)
{
unsigned int a[3] = {0x01020304, 0x05060708, 0x090a0b0c};
unsigned int *p = (unsigned int *)((int)a +1);¢Ù
printf("%x\n", *p);
return 0;
}
¡¾ÌâÄ¿½âÎö¡¿
Õâ¶Î³ÌÐòµÄÊä³ö½á¹ûÓ¦ ......
C/VCĿ¼²Ù×÷
Ðdz¾ ·¢±íÓÚ 2006-10-11 15:54:00
0
ÍƼö
Ò»¡¢Ä¿Â¼²Ù×÷º¯Êý½éÉÜ
ÔÚVC++µÄ“direct.h”Öж¨ÒåÁËÒÔÏÂ4¸öº¯Êý£º
int chdir(const char *); //change directory
char * getcwd(char *, int); //get current working directory
int mkdir(const cha ......
¸Ã³ÌÐòºÜ¼òµ¥£¬¾ÍÊÇÓÃC´ÓORACLE£¬°Ñµ±Ç°ÈÕÆÚÏÔʾ³öÀ´¾ÍOK£¬×÷Ϊһ¸ö¼òµ¥µÄDEMO
£¨Ò»£©Ð´PRO*C
/*===========================================================================
* pro*c±àÒë·½·¨£º
* Ô¤±àÒë proc test.pc
* ±àÒë gcc -o test test.c $ORACLE_HOME/lib/libclntsh.so
* ×÷Õß f ......
ÓÃC/C£«£«Ð´CGI³ÌÐò
ʹÓÃCGIC¿âµÄ¼òÒª£º
¿âµÄº¯Êý˵Ã÷£º http://www.boutell.com/cgic/#cgiFormStringNoNewlines
1. ´òÓ¡CGI±ê×¼Êä³öÍ·²¿£º
cgiHeaderContentType£¨"text/plain"£©£»
»òÕߣº
......