c/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æÇé¿ö ÎÄ×Ö³£Á¿Çø
Ê×ÏÈ¿´ÏÂÏÂÃæÕâ¶Î£º
int main()
{
char *name = "fengkewei";
char name1[] = "fengkewei";
char *name2 = "fengkewei";
char *name3 = "woaifengkewei";
int i = 10;
int j = 10;
int k = 11;
return 0;
}
ÈôÄú¾õµÃËüÃÇÓ¦¸Ã¶¼±£´æÔÚÄÚ´æÖеÄÒ»¿éµØ·½£¬ÄÇÇëÍùÏ¿´¡£¡£¡£¡£
ÏÂÃæÊDZàÒëÆ÷Ϊ¸÷¸ö±äÁ¿·ÖÅäµÄÄÚ´æµØÖ·£¬ÓÉÓÚ·ÖÅäÔÚÕ»ÉÏ ËùÒÔµØÖ·ÊǵݼõµÄ
---------------------Õ»Çø------------------------------------
+ &name 0x0013ff5c unsigned char * *
+ &name1 0x0013ff48 unsigned char [10]*
+ &name2 0x0013ff3c unsigned char * *
+ &name3 0x0013ff30 unsigned char * *
+ &i 0x0013ff24 int *
+ &j 0x0013ff18 int *
+ &k 0x0013ff0c int *
---------------------------------------------------------------
&name ºÍ&name1[] Ïà²î20¸ö×Ö½Ú µ«"fengkewei"Ö»ÓÐ10¸ö×Ö½Ú£¨´ø¿Õ×Ö·û£©
&name1[]ºÍ&name2 Ïà²î12¸ö×Ö½Ú
ºóÃ涼Õý³£ÁË ¶¼²î12
ΪʲôÊÇ12£¿
————————————————————————————————————————————
ÏÂÃæÊǸ÷×Ö·û´®µÄÊ×µØÖ· ËüÃǶ¼ÔÚÎÄ×Ö³£Á¿ÇøÀï ÏàͬҲ¾ÍÏàͬÁË ²»Í¬ÔòÊǵÝÔö·ÖÅäµÄ£¨ ÎÄ×Ö³£Á¿ÇøÒ²ÊǵÝÔö·ÖÅäµÄ)
---------------------------ÎÄ×Ö³£Á¿Çø-------------------------------------------------
+ name 0x004156b8 "fengkewei" unsigned char *
+ name2 0x004156b8 "fengkewei" unsigned char *
+ name3 0x00416010 "woaifengkewei" unsigned char *
+ name1 0x0013ff48 "fengkewei" unsigned char [10]
¿É¼ûname1[]ÊÇÔÚÒ»¸ö²»Í¬µÄµØ·½µÄ Ò²¾ÍÊÇ˵Ëü¾ÍÊÇÔÚÕ»ÉÏ
ÏÖÔÚÎÒÃÇÉèÖÃÒ»¸öÕûÐÍÖ¸Õë
int *p;
p = &i;
ÄÇpµÄµØÖ·Ó¦¸ÃÊÇÖ¸ÏòiµÄµØÖ·£¬Ö¸ÏòÕ»Çø
¹ûÈ»£º
+ &i 0x0013ff24 int *
+ p 0x0013ff24 int *
----------------------------------------------------------
Ïà¹ØÎĵµ£º
ͨÐÅ
Server£º
#pragma comment(lib, "ws2_32.lib")
#include <Winsock2.h>
#include <stdio.h>
void main()
{
//°æ±¾ÐÉÌ
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(1,1); //0x0101
err = WSAStartup ......
´´½¨Ð½ø³Ì£ºforkº¯Êý
1.1.1. forkº¯Êý¸Éʲô£¿
#include <sys/types.h>
#include <unistd.h>
pid_t fork(void);
‘fork()’º¯ÊýÓÃÓÚ´ÓÒÑ´æÔÚ½ø³ÌÖд´½¨Ò»¸öнø³Ì¡£Ð½ø³Ì³ÆΪ×Ó½ ......
Óõ¥ÒýºÅÒýÆðµÄÒ»¸ö×Ö·ûʵ¼ÊÉÏ´ú±íÒ»¸öÕûÊý£¬ÕûÊýÖµ¶ÔÓ¦ÓÚ¸Ä×Ö·ûÔÚ±àÒëÆ÷²ÉÓõÄ×Ö·û¼¯ÖеÄÐòÁÐÖµ¡£
ÓÃË«ÒýºÅÒýÆðµÄ×Ö·û´®£¬´ú±íµÄÊÇÒ»¸öÖ¸ÏòÎÞÃûÊý×éÆðʼ×Ö·ûµÄÖ¸Õ룬¸ÃÊý×鱻˫ÒýºÅÖ®¼äµÄ×Ö·ûÒÔ¼°Ò»¸ö¶îÍâµÄ¶þ½øÖÆֵΪÁãµÄ×Ö·û'\0'³õʼ»¯¡£
printf("Hello world\n");
Óë
char hello[] = {'H', 'e', 'l', 'l', 'o', ' ' ......
ÓÃ#include¿ÉÒÔ°üº¬ÆäËûÍ·ÎļþÖбäÁ¿¡¢º¯ÊýµÄÉùÃ÷£¬ÎªÊ²Ã´»¹Òªextern¹Ø¼ü×Ö,Èç¹ûÎÒÏëÒýÓÃÒ»¸öÈ«¾Ö±äÁ¿»ò
º¯Êýa£¬ÎÒÖ»ÒªÖ±½ÓÔÚÔ´ÎļþÖаüº¬#include<xxx.h>
(xxx.h°üº¬ÁËaµÄÉùÃ÷)²»¾Í¿ÉÒÔÁËô£¬ÎªÊ²Ã´»¹ÒªÓÃexternÄØ£¿£¿Õâ¸öÎÊÌâÒ»Ö±Ò²ÊÇËÆÊǶø·ÇµÄÀ§ÈÅ×ÅÎÒÐí¶àÄêÁË£¬½ñÌìÉÏÍøºÝºÝ²éÁËÒ»ÏÂ×ÜËãСÓÐ
Ëù»ñÁË£º
Í· ......