c±àÒë¹ý³Ì
±àÒëµÄ¸ÅÄ±àÒë³ÌÐò¶ÁÈ¡Ô´³ÌÐò£¨×Ö·ûÁ÷£©£¬¶ÔÖ®½øÐдʷ¨ºÍÓï·¨µÄ·ÖÎö£¬½«¸ß¼¶ÓïÑÔÖ¸Áîת»»Îª¹¦ÄܵÈЧµÄ»ã±à´úÂ룬ÔÙÓÉ»ã±à³ÌÐòת»»Îª»úÆ÷ÓïÑÔ£¬²¢ÇÒ°´ÕÕ²Ù×÷ϵͳ¶Ô¿ÉÖ´ÐÐÎļþ¸ñʽµÄÒªÇóÁ´½ÓÉú³É¿ÉÖ´ÐгÌÐò¡£
±àÒëµÄÍêÕû¹ý³Ì£ºCÔ´³ÌÐò££>Ô¤±àÒë´¦Àí(.c)££>±àÒë¡¢ÓÅ»¯³ÌÐò£¨.s¡¢.asm£©££>»ã±à³ÌÐò(.obj¡¢.o¡¢.a¡¢.ko)££>Á´½Ó³ÌÐò£¨.exe¡¢.elf¡¢.axfµÈ£©
1. ±àÒëÔ¤´¦Àí
¶ÁÈ¡cÔ´³ÌÐò£¬¶ÔÆäÖеÄαָÁÒÔ#¿ªÍ·µÄÖ¸ÁºÍÌØÊâ·ûºÅ½øÐд¦Àí
αָÁîÖ÷Òª°üÀ¨ÒÔÏÂËĸö·½Ã棺
£¨1£©ºê¶¨ÒåÖ¸ÁÈç#define Name TokenString£¬#undefµÈ¡£
¶ÔÓÚÇ°Ò»¸öαָÁԤ±àÒëËùÒª×öµÄÊǽ«³ÌÐòÖеÄËùÓÐNameÓÃTokenStringÌæ»»£¬µ«×÷Ϊ×Ö·û´®³£Á¿µÄ NameÔò²»±»Ìæ»»¡£¶ÔÓÚºóÕߣ¬Ôò½«È¡Ïû¶Ôij¸öºêµÄ¶¨Ò壬ʹÒÔºó¸Ã´®µÄ³öÏÖ²»ÔÙ±»Ìæ»»¡£
£¨2£©Ìõ¼þ±àÒëÖ¸ÁÈç#ifdef£¬#ifndef£¬#else£¬#elif£¬#endifµÈ¡£
ÕâЩαָÁîµÄÒýÈëʹµÃ³ÌÐòÔ±¿ÉÒÔͨ¹ý¶¨Ò岻ͬµÄºêÀ´¾ö¶¨±àÒë³ÌÐò¶ÔÄÄЩ´úÂë½øÐд¦Àí¡£Ô¤±àÒë³ÌÐò½«¸ù¾ÝÓйصÄÎļþ£¬½«ÄÇЩ²»±ØÒªµÄ´úÂë¹ýÂ˵ô
£¨3£© Í·Îļþ°üº¬Ö¸ÁÈç#include "FileName"»òÕß#include FileName>µÈ¡£
ÔÚÍ·ÎļþÖÐÒ»°ãÓÃαָÁî#define¶¨ÒåÁË´óÁ¿µÄºê£¨×î³£¼ûµÄÊÇ×Ö·û³£Á¿£©£¬Í¬Ê±°üº¬Óи÷ÖÖÍⲿ·ûºÅµÄÉùÃ÷¡£
²ÉÓÃÍ·ÎļþµÄÄ¿µÄÖ÷ÒªÊÇΪÁËʹijЩ¶¨Òå¿ÉÒÔ¹©¶à¸ö²»Í¬µÄCÔ´³ÌÐòʹÓá£ÒòΪÔÚÐèÒªÓõ½ÕâЩ¶¨ÒåµÄCÔ´³ÌÐòÖУ¬Ö»Ðè¼ÓÉÏÒ»Ìõ#includeÓï¾ä¼´¿É£¬¶ø²»±ØÔÙÔÚ´ËÎļþÖн«ÕâЩ¶¨ÒåÖظ´Ò»±é¡£Ô¤±àÒë³ÌÐò½«°ÑÍ·ÎļþÖеĶ¨Òåͳͳ¶¼¼ÓÈëµ½ËüËù²úÉúµÄÊä³öÎļþÖУ¬ÒÔ¹©±àÒë³ÌÐò¶ÔÖ®½øÐд¦Àí¡£
°üº¬µ½cÔ´³ÌÐòÖеÄÍ·Îļþ¿ÉÒÔÊÇϵͳÌṩµÄ£¬ÕâЩͷÎļþÒ»°ã±»·ÅÔÚ/usr/includeĿ¼Ï¡£ÔÚ³ÌÐòÖÐ#includeËüÃÇҪʹÓüâÀ¨ºÅ£¨ >£©¡£ÁíÍ⿪·¢ÈËÔ±Ò²¿ÉÒÔ¶¨Òå×Ô¼ºµÄÍ·Îļþ£¬ÕâЩÎļþÒ»°ãÓëcÔ´³ÌÐò·ÅÔÚͬһĿ¼Ï£¬´ËʱÔÚ#includeÖÐÒªÓÃË«ÒýºÅ£¨""£©¡£
£¨4£©ÌØÊâ·ûºÅ£¬Ô¤±àÒë³ÌÐò¿ÉÒÔʶ±ðһЩÌØÊâµÄ·ûºÅ¡£
ÀýÈçÔÚÔ´³ÌÐòÖгöÏÖµÄLINE±êʶ½«±»½âÊÍΪµ±Ç°Ðкţ¨Ê®½øÖÆÊý£©£¬FILEÔò±»½âÊÍΪµ±Ç°±»±àÒëµÄCÔ´³ÌÐòµÄÃû³Æ¡£Ô¤±àÒë³ÌÐò¶ÔÓÚÔÚÔ´³ÌÐòÖгöÏÖµÄÕâЩ´®½«ÓúÏÊʵÄÖµ½øÐÐÌæ»»¡£
Ô¤±àÒë³ÌÐòËùÍê³ÉµÄ»ù±¾ÉÏÊǶÔÔ´³ÌÐòµÄ“Ìæ´ú”¹¤×÷¡£¾¹ý´ËÖÖÌæ´ú£¬Éú³ÉÒ»¸öûÓк궨Ò塢ûÓÐÌõ¼þ±àÒëÖ¸ÁûÓÐÌØÊâ·ûºÅµÄÊä³öÎļþ¡£Õâ¸öÎļþµÄº¬ÒåͬûÓо¹ýÔ¤´¦ÀíµÄÔ´Î
Ïà¹ØÎĵµ£º
¼ò½é
±¾ÎÄÊÇΪÁËÂú×㿪·¢ÈËÔ±µÄÐèÒª¶øдµÄ¡£ÎÒÃÇ×ܽáÁËÒ»Ì×Ö¸ÄÏ£¬ÎÞÂÛ×÷Ϊ¿ª·¢ÈËÔ±»¹ÊǹËÎÊ£¬ÕâЩָÄ϶àÄêÀ´Ò»Ö±¶¼ºÜºÃµØÖ¸µ¼×ÅÎÒÃÇ£¬ÎÒÃÇ°ÑËüÃÇ×÷Ϊ½¨ÒéÌṩ¸øÄú£¬Ï£Íû¶ÔÄúµÄ¹¤×÷ÓÐËù°ïÖú¡£ÄúÒ²Ðí²»ÔÞͬÆäÖеÄijЩָÄÏ£¬µ«ÎÒÃÇÏ£ÍûÄú»áϲ»¶ÆäÖеÄһЩ²¢ÔÚÄúµÄ±à³Ì»òÒÆÖ²ÏîÄ¿ÖÐʹÓÃËüÃÇ¡£
·ç¸ñÓëÖ¸ÄÏ
ʹÓÃÒ»ÖÖʹ´úÂë¾ß ......
1. CµÄʵÏÖ
//stack.h
#ifndef STACK_H
#define STACK_H
#define STACK_CAPACITY 20//maximum size of stack
typedef int stackEle;
typedef struct
{
stackEle myArray[ STACK_CAPACITY ];
int myTop;
}stack;
//construct(initialize) an empty stack
stack *stack_init(void);
//return 1 if stack is em ......
Ò»¡¢Ê²Ã´ÊÇc/sºÍb/s
ÒªÏë¶Ô“c/s”ºÍ“b/s”¼¼Êõ·¢Õ¹±ä»¯ÓÐËùÁ˽⣬Ê×ÏȱØÐë¸ãÇå³þÈý¸öÎÊÌâ¡£
µÚÒ»¡¢Ê²Ã´ÊÇc/s½á¹¹¡£
c/s£¨client/server£©½á¹¹£¬¼´´ó¼ÒÊìÖªµÄ¿Í»§»úºÍ·þÎñÆ÷½á¹¹¡£ËüÊÇÈí¼þϵͳÌåϵ½á¹¹£¬Í¨¹ýËü¿ÉÒÔ³ä·ÖÀûÓÃÁ½¶ËÓ²¼þ»·¾³µÄÓÅÊÆ£¬½«ÈÎÎñºÏÀí·ÖÅäµ½client¶ËºÍserver¶ËÀ´ÊµÏÖ£¬½µµÍÁ ......
1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«ÎªÄã¼ÆËã³£Êý±í´ïʽµÄÖµ£¬Òò´Ë£¬Ö±½Óд³öÄãÊÇÈçºÎ¼ÆËãÒ»ÄêÖÐÓж ......
Ò»¸öÓÉC/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å
£¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£© — Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å
£¬
Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅä·½ ......