DS¼Æ»®CÉîÈëѧϰÏîÄ¿£º¡¾×ܽ᡿¡¾±äÁ¿¡¿±äÁ¿µÄ´æ´¢Óò
Èç¹ûÒª¼ÓÈë´Ë¼Æ»®:
1¡¢
·½Ê½1
£º¼ÓÈë
QQ
Ⱥ£º
93684322
¡£
2¡¢
·½Ê½2
£º¼ÓÈë
CSDN
Ⱥ×飺
DS¼Æ»®
¡£
1.1 ±äÁ¿´æ´¢Óò
1.1.1 Ò»¸öʾÀý
pang123huiÊ×ÏÈÌṩÁËÒ»¸öÍøÉÏÁ÷´«µÄѧϰ´úÂëʾÀý£º
int a = 0; //È«¾ÖÇø
void main()
{
int b; //Õ»
char s[] = “abc”; //sÔÚÕ»,abcÔÚÎÄ×Ö³£Á¿Çø
char *p1,*p2; //Õ»
char *p3 = "123456"; //123456ÔÚ³£Á¿Çø£¬p3ÔÚÕ»ÉÏ
static int c =0; //È«¾ÖÇø
p1 = (char *)malloc(10); //p1ÔÚÕ»£¬·ÖÅäµÄ10×Ö½ÚÔÚ¶Ñ
p2 = (char *)malloc(20); //p2ÔÚÕ»£¬·ÖÅäµÄ20×Ö½ÚÔÚ¶Ñ
strcpy(p1, "123456"); //123456·ÅÔÚ³£Á¿Çø
}
Õâ¸ö´úÂëʾÀýÖгöÏÖÁË“È«¾ÖÇø”£¬“Õ»”£¬“ÎÄ×Ö³£Á¿Çø”£¬“¶Ñ”µÈ´ÊÓΪÁËͳһ£¬ÎÒÃÇʹÓá¶Cר¼Ò±à³Ì¡·ÖеÄ˵·¨£º¶ÑÕ»¶Î£¬BSS¶Î£¬Êý¾Ý¶Î£¬Îı¾¶Î¡£
¸÷¸ö¶ÎµÄ×÷ÓÃÈçÏ£º
1¡¢ Îı¾¶Î£º°üº¬³ÌÐòµÄÖ¸ÁËüÔÚ³ÌÐòµÄÖ´Ðйý³ÌÖÐÒ»°ã²»»á¸Ä±ä¡£
2¡¢ Êý¾Ý¶Î£º°üº¬Á˾¹ý³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿£¬ÒÔ¼°ËûÃǵÄÖµ¡£
3¡¢ BSS¶Î£º°üº¬Î´¾³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿¡£
4¡¢ ¶ÑÕ»¶Î£º°üº¬Á˺¯ÊýÄÚ²¿ÉùÃ÷µÄ¾Ö²¿±äÁ¿¡£
µ±È»£¬ÉÏÃæ¶ÎµÄ×÷Óò»½öÓÚ´Ë£¬¾ßÌåµÄ×÷ÓûáÔÚÏÂÃæµÄ֪ʶµãÖнéÉÜ¡£
1.1.2 ͨ¹ý´úÂë²âÊÔ±äÁ¿µÄ´æ´¢Î»ÖÃ
LinuxÏ¿ÉÒÔͨ¹ýϵͳÃüÁî“size”²é¿´¿ÉÒÔÖ´ÐгÌÐò¸÷¸ö¶ÎµÄ´óС¡£µ«ÊÇ£¬¿ÉÖ´ÐгÌÐòÖеĶνṹºÍÔËÐÐÖгÌÐòÔÚÄÚ´æÖеĶνṹ²¢²»ÍêÈ«Ïàͬ£¬µ«ÊÇÓÐÒ»¶¨µÄÓ³Éä¹Øϵ¡£¾ßÌåÈçÏÂͼËùʾ£¨Í¼Æ¬ÐÅÏ¢À´×Ô¡¶Cר¼Ò±à³Ì¡·£©£º
ÏÂÃæͨ¹ý´úÂëʾÀýºÍ“size”À´Ñо¿±äÁ¿µÄ´æ´¢ÇøÓò¡£
test.c
int main()
{
return 1;
}
±àÒ룬²¢ÇҲ鿴¿ÉÖ´ÐгÌÐò¸÷¸ö¶ÎµÄ´óС£º
¸ü¸Ätest.c£º
int g_data;
int main()
{
return 1;
}
±àÒ룬²¢ÇҲ鿴¿ÉÖ´ÐгÌÐò¸÷¸ö¶ÎµÄ´óС£º
¿ÉÒÔ·¢ÏÖ£¬Îı¾¶Î£¬Êý¾Ý¶Î¶¼Ã»Óз¢Ëͱ仯£¬¶øBSS¶ÎÔö¼ÓÁË4¸ö×Ö½Ú¡£
½áÂÛ1£ºÎ´³õʼ»¯µÄÈ«¾Ö±äÁ¿±£´æÔÚBSS¶ÎÖÐ
¼ÌÐø£º
int g_data = 1;
int main()
{
return 1;
}
±àÒ룺
¿ÉÒÔ·¢ÏÖ£¬BSS¶ÎºÍÎı¾¶ÎÏàͬ£¬¶øÊý¾Ý¶ÎÔö¼ÓÁË4¸ö×Ö½Ú¡£
½áÂÛ2£º¾¹ý³õʼ»¯µÄÈ«¾Ö±äÁ¿±£´æÔÚÊý¾Ý¶ÎÖÐ
¼ÌÐø£º
int main()
{
static int g_data;
return 1;
}
±àÒ룺
¿ÉÒÔ·¢Ï
Ïà¹ØÎĵµ£º
È¥Äê ÎÒÃÇͨ¹ýÁ˼ÆËã»ú¶þ¼¶µÄ¿¼ºË£¬½ÓÏÂÀ´ÃæÁٵľÍÊÇÈý¼¶µÄ¿¼ÑéÁË£¬
ÓôÃƵÄÊÇ ²»ÖªµÀÊÇÑ¡ÔñÄÄÖÖÓïÑԺã¡
Èý¼¶ÉÏ»ú ¹æ¶¨µÄÓïÑÔÊÇCÓïÑÔ£¬ÎÒѧµÄÊÇC++£¬ÀÏʦ˵£ºÕâ¶ÔÄãµÄÉÏ»ú¿¼ÊÔʱÓÐÓ°ÏìµÄ£¡
´Ó³¤Ô¶½Ç¶È¿´£ºC++±ÈCÓïÑÔÓÐןü¼Ó¹ãÀ«µÄÇ°¾°£»¶øCÓïÑÔ¶ÔÓÚÉÏ»ú¿¼ÊÔ ºÃÈÝÒ×ÉÏÊÖ£¡
ÓôÃÆ¡£¡£¡£¡£¡£¡£ ......
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë ¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨ Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/&nbs ......
1£ºÀàËÆjunitµÄ¶ÏÑÔ£¬Ö»ÊÇÔÚassertÖеĶÏÑÔ£¬Èç¹û²»Âú×ãµÄ»°¾Í³ÌÐòÍ˳ö¡£
±ÈÈç
#include <assert.h>
int main(void)
{
assert(6 < 5);
system("pause");
return 0;
}
ÔÚÖ´Ðе½assert(6 < 5);
µÄʱºòÒòΪ²»Âú×ã¶ÏÑÔ£¬ÓÚÊdzÌÐòÍ˳ö¡£
Èç¹û²»ÏëÈÃassert(6 < 5)Æð×÷Ó㬾ÍÔÚ×îÉÏÃæÌí¼Óºê¶¨Òå# ......
CÓïÑԵĻص÷º¯Êý˼Ïë´úÂ룺
#include <stdio.h>
void *max(void *base, unsigned int nmemb, unsigned int size,
int (*compar)(const void *, const void *))
{
int i;
void* max_data = base;
char* tmp = base;
&nbs ......
/*
* Exercise 2-5 Page 48
*
* Write the function any(s1,s2), which returns the first location
* in the string s1 where any character from the string s2 occurs,
* or -1 if s1 contains no characters from s2. (The standard library
* function strpbrk does the same job but returns a pointer t ......