Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

´ÓÁ½µÀ¾­µäÊÔÌâ̸C/C++ÖÐÁªºÏÌ壨union£©µÄʹÓÃ


´ÓÁ½µÀ¾­µäÊÔÌâ̸C/C++ÖÐÁªºÏÌ壨union£©µÄʹÓÃ
ÊÔÌâÒ»£º±àдһ¶Î³ÌÐòÅжÏϵͳÖеÄCPUÊÇLittle endian»¹ÊÇBig endianģʽ£¿
·ÖÎö£º
×÷Ϊһ¸ö¼ÆËã»úÏà¹ØרҵµÄÈË£¬ÎÒÃÇÓ¦¸ÃÔÚ¼ÆËã»ú×é³ÉÖж¼Ñ§Ï°¹ýʲô½ÐLittle endianºÍBig endian¡£Little endianºÍBig endianÊÇCPU´æ·ÅÊý¾ÝµÄÁ½ÖÖ²»Í¬Ë³Ðò¡£¶ÔÓÚÕûÐÍ¡¢³¤ÕûÐ͵ÈÊý¾ÝÀàÐÍ£¬Big endianÈÏΪµÚÒ»¸ö×Ö½ÚÊÇ×î¸ßλ×Ö½Ú£¨°´Õմӵ͵ØÖ·µ½¸ßµØÖ·µÄ˳Ðò´æ·ÅÊý¾ÝµÄ¸ßλ×Ö½Úµ½µÍλ×Ö½Ú£©£»¶øLittle endianÔòÏà·´£¬ËüÈÏΪµÚÒ»¸ö×Ö½ÚÊÇ×îµÍλ×Ö½Ú£¨°´Õմӵ͵ØÖ·µ½¸ßµØÖ·µÄ˳Ðò´æ·ÅÊý¾ÝµÄµÍλ×Ö½Úµ½¸ßλ×Ö½Ú£©¡£
ÀýÈ磬¼ÙÉè´ÓÄÚ´æµØÖ·0x0000¿ªÊ¼ÓÐÒÔÏÂÊý¾Ý£º
0x0000
0x0001
0x0002
0x0003
0x12
0x34
0xab
0xcd
Èç¹ûÎÒÃÇÈ¥¶ÁÈ¡Ò»¸öµØַΪ0x0000µÄËĸö×Ö½Ú±äÁ¿£¬Èô×Ö½ÚÐòΪbig-endian£¬Ôò¶Á³ö½á¹ûΪ0x1234abcd£»Èô×Ö½ÚÐòλlittle-endian£¬Ôò¶Á³ö½á¹ûΪ0xcdab3412¡£Èç¹ûÎÒÃǽ«0x1234abcdдÈëµ½ÒÔ0x0000¿ªÊ¼µÄÄÚ´æÖУ¬ÔòLittle endianºÍBig endianģʽµÄ´æ·Å½á¹ûÈçÏ£º
µØÖ·
0x0000
0x0001
0x0002
0x0003
big-endian
0x12
0x34
0xab
0xcd
little-endian
0xcd
0xab
0x34
0x12
Ò»°ãÀ´Ëµ£¬x86ϵÁÐCPU¶¼ÊÇlittle-endianµÄ×Ö½ÚÐò£¬PowerPCͨ³£ÊÇBig endian£¬»¹ÓеÄCPUÄÜͨ¹ýÌøÏßÀ´ÉèÖÃCPU¹¤×÷ÓÚLittle endian»¹ÊÇBig endianģʽ¡£
½â´ð£º
ÏÔÈ»£¬½â´ðÕâ¸öÎÊÌâµÄ·½·¨Ö»ÄÜÊǽ«Ò»¸ö×Ö½Ú£¨CHAR/BYTEÀàÐÍ£©µÄÊý¾ÝºÍÒ»¸öÕûÐÍÊý¾Ý´æ·ÅÓÚͬÑùµÄÄڴ濪ʼµØÖ·£¬Í¨¹ý¶ÁÈ¡ÕûÐÍÊý¾Ý£¬·ÖÎöCHAR/BYTEÊý¾ÝÔÚÕûÐÍÊý¾ÝµÄ¸ßλ»¹ÊǵÍλÀ´ÅжÏCPU¹¤×÷ÓÚLittle endian»¹ÊÇBig endianģʽ¡£µÃ³öÈçϵĴ𰸣º
typedef unsigned char BYTE;
int main(int argc, char* argv[])
{
        unsigned int num,*p;
     p = #
        num = 0;
     *(BYTE *)p = 0xff;
       
        if(num == 0xff)
        {
               printf("The endian of cpu is little\n");
        }
        else   &nbs


Ïà¹ØÎĵµ£º

CºêµÄÓ÷¨

Ç°¼¸Ìì²Î¼Óij¹«Ë¾µÄ±ÊÊÔ£¬ÓÐÒ»µÀÌâÊÇÓô¿CʵÏÖÒ»¸ö·ºÐͺ¯Êý¡£ÓôÃÆÁ˺þÃÓÃC++Ä£°åʵÏÖÁË¡£
ºêÓÐÈçϵÄÌص㣺
1.ÓëconstÏà±È£¬ºêÊÇÔÚÔ¤±àÒëµÄʱºòÍê³ÉµÄ
2.define Ö»×ö¼òµ¥µÄÌæ»»£¬²»×öÀàÐÍ°²È«¼ì²é
3.ʹÓò»µ±»áÒýÆðºÜ¶àÎÊÌâ
ºêµÄÓ÷¨£º
1.¼òµ¥µÄºê¶¨Òå
#define  MAX 1024
2.ºê¶¨Ò幦ÄÜ¿é
#define MAX(a,b) ( ......

linux cÎÊÌ⼯½õ

1.ΪʲôÎÒдµÄMakefile£¬Ôڱ༭ÁËÔ´´úÂëÎļþºó£¬Ê¹ÓÃmake£¬makeÈ´ÌáʾĿ±êÎļþÒѾ­Îª×îеÄÁË£¡
2.OpenGL,ÔÚ´°¿ÚÖл­µãʱ£¬ÔõÑùʹÓÃglVertexi()º¯Êý£¿ÒòΪ´«µÝµÄ²ÎÊýÈç¹ûÊÇ´óÓÚ1µÄintÐÍ£¬Ôò²»ÐУ¬¶ø±ØÐë´«µÝ[-0.1~0.1]Ö®¼äµÄfloat£¬¶øÇÒʹÓú¯Êý
gVertex2f().
3.OpenGL,ʹÓò˵¥Ê±£¬ÔõÑù½â¾öµã»÷²Ëµ¥ºó²»Òª²¶×½GLUT_UPÊ ......

LinuxÏÂc³ÌÐò¿ª·¢±Ê¼Ç

 µÚÒ»ÕÂ
1.
½âÊÍÐÔÓïÑÔ£ºshell  javascript python  ±à³ÌÈËÔ±²»ÐèÒª¾­¹ý±àÒë Á¬½ÓµÄ¹ý³Ì£¬¿ÉÒÔÔÚÌض¨»·¾³ÏÂÖ±½ÓÖ´ÐеÄÓïÑÔ  ×Ô¶¯±àÒëÁ¬½Ó¡£¿ª·¢Ð§Âʸߣ¬µ«ÔËÐÐЧÂʵ͡£
±àÒëÐÍÓïÑÔ£ºjava c c++£¬ÐèÒª¾­¹ý±à³ÌÈËÔ±¾­¹ý±àÒëºÍÁ¬½Ó²úÉú¿ÉÖ´ÐгÌÐòµÄÓïÑÔ¡£ÔËÐÐЧÂʸߡ£
2.
Êý¾Ý
Êý¾Ý½á¹¹£ºÊý¾ÝÖ®¼äµÄ ......

c socket ·¢ËÍhttpÇëÇó

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(){
int sockfd;
int len;
struct sockaddr_in address;
int result;
char *strings="GET /svnup/rewrite.php HTTP/1 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ