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

CÓïÑÔÎļþÏà¹Ø²Ù×÷

CÓïÑÔÎļþ²Ù×÷½Ó´¥ºÜ¾ÃÁË£¬Ò»Ö±Ã»ÓÐ×ܽáÏà¹ØÄÚÈÝ£¬½ñÌìÓõ½Á˾ÍÈ¥ÕÒÁËÕÒÏà¹ØÄÚÈÝ¡£
ÔÚANSI CÖУ¬¶ÔÎļþµÄ²Ù×÷·ÖΪÁ½ÖÖ·½Ê½£¬¼´Á÷ʽÎļþ²Ù×÷ºÍI/OÎļþ²Ù×÷
typedef struct {
int level; /* fill/empty level of buffer */
unsigned flags; /* File status flags */
char fd; /* File descriptor */
unsigned char hold; /* Ungetc char if no buffer */
int bsize; /* Buffer size */
unsigned char _FAR *buffer; /* Data transfer buffer */
unsigned char _FAR *curp; /* Current active pointer */
unsigned istemp; /* Temporary file indicator */
short token; /* Used for validity checking */
} FILE; /* This is the FILE object */
VCÖÐFILEµÄ¶¨ÒåΪ
struct _iobuf {
char *_ptr; //ÎļþÊäÈëµÄÏÂÒ»¸öλÖÃ
int _cnt; //µ±Ç°»º³åÇøµÄÏà¶ÔλÖÃ
char *_base; //Ö¸»ù´¡Î»ÖÃ(¼´ÊÇÎļþµÄÆäʼλÖÃ)
int _flag; //Îļþ±êÖ¾
int _file; //ÎļþµÄÓÐЧÐÔÑéÖ¤
int _charbuf; //¼ì²é»º³åÇø×´¿ö,Èç¹ûÎÞ»º³åÇøÔò²»¶ÁÈ¡
int _bufsiz; //ÎļþµÄ´óС
char *_tmpfname; //ÁÙʱÎļþÃû
};
typedef struct _iobuf FILE;

FILEÕâ¸ö½á¹¹°üº¬ÁËÎļþ²Ù×÷µÄ»ù±¾ÊôÐÔ£¬¶ÔÎļþµÄ²Ù×÷¶¼ÒªÍ¨¹ýÕâ¸ö½á¹¹µÄÖ¸ÕëÀ´½øÐС£
Îļþ´ò¿ªº¯Êýfopen
¡¡¡¡fopenº¯ÊýÓÃÀ´´ò¿ªÒ»¸öÎļþ£¬Æäµ÷ÓõÄÒ»°ãÐÎʽΪ£º
ÎļþÖ¸ÕëÃû=fopen(ÎļþÃû£¬Ê¹ÓÃÎļþ·½Ê½) ÆäÖУ¬“ÎļþÖ¸ÕëÃû”±ØÐëÊDZ»ËµÃ÷ΪFILE ÀàÐ͵ÄÖ¸Õë±äÁ¿£¬“ÎļþÃû”ÊDZ»´ò¿ªÎļþµÄÎļþÃû¡£
“ʹÓÃÎļþ·½Ê½”ÊÇÖ¸ÎļþµÄÀàÐͺͲÙ×÷ÒªÇ󡣓ÎļþÃû”ÊÇ×Ö·û´®³£Á¿»ò×Ö·û´®Êý×é¡£ÀýÈ磺
FILE *fp£»
fp=("file a","r");
ÆäÒâÒåÊÇÔÚµ±Ç°Ä¿Â¼Ï´ò¿ªÎļþfile a£¬ Ö»ÔÊÐí½øÐГ¶Á”²Ù×÷£¬²¢Ê¹fpÖ¸Ïò¸ÃÎļþ¡£
ÓÖÈ磺
FILE *fphzk
fphzk=("c:\hzk16',"rb")
ÆäÒâÒåÊÇ´ò¿ªCÇý¶¯Æ÷´ÅÅ̵ĸùĿ¼ÏµÄÎļþhzk16£¬ ÕâÊÇÒ»¸ö¶þ½øÖÆÎļþ£¬Ö»ÔÊÐí°´¶þ½øÖÆ·½Ê½½øÐжÁ²Ù×÷¡£Á½¸ö·´Ð±Ïß“\ ”ÖеĵÚÒ»¸ö±íʾתÒå×Ö·û£¬µÚ¶þ¸ö±íʾ¸ùĿ¼¡£Ê¹ÓÃÎļþµÄ·½Ê½¹²ÓÐ12ÖÖ£¬ÏÂÃæ¸ø³öÁËËüÃǵķûºÅºÍÒâÒå¡£
ÎļþʹÓ÷½Ê½ ¡¡¡¡¡¡¡¡¡¡¡¡¡¡Òâ Òå
“rt”¡¡¡¡¡¡¡¡¡¡¡¡Ö»¶Á´ò¿ªÒ»¸öÎı¾Îļþ£¬Ö»ÔÊÐí¶ÁÊý¾Ý
“wt&r


Ïà¹ØÎĵµ£º

CÓïÑÔÎļþ

13.1 CÎļþ¸ÅÊö
    Ëùν“Îļþ”ÊÇÖ¸Ò»×éÏà¹ØÊý¾ÝµÄÓÐÐò¼¯ºÏ¡£Õâ¸öÊý¾Ý¼¯ÓÐÒ»¸öÃû³Æ£¬½Ð×öÎļþÃû¡£Êµ¼ÊÉÏÔÚÇ°ÃæµÄ¸÷ÕÂÖÐÎÒÃÇÒѾ­¶à´ÎʹÓÃÁËÎļþ£¬ÀýÈçÔ´³ÌÐòÎļþ¡¢Ä¿±êÎļþ¡¢¿ÉÖ´ÐÐÎļþ¡¢¿âÎļþ (Í·Îļþ)µÈ¡£
    Îļþͨ³£ÊÇפÁôÔÚÍⲿ½éÖÊ(Èç´ÅÅ̵È)Éϵģ¬ÔÚʹÓÃʱ²Åµ÷ÈëÄÚ´æÖ ......

Õ»µÄCʵÏÖ(stack)

rows="2" cols="20" id="ctl00_ctl00_cphContent_cphDoc_EntryEditor1_richTextEditor" class="mceEditor" style="height:450px;width:100%;">
Õ»ÊÇÊý¾Ý½á¹¹ÖÐ×î»ù´¡Ò²ÊÇ×î¾­µäµÄÊý¾Ý½á¹¹£¬ÎÞÂÛÔÚÓ¦Óû¹ÊDzÙ×÷ϵͳÖоù¿ÉÒÔ¿´µ½ÆäÉíÓ°¡£Õ»ÊÇÒ»ÖÖÌØÊâµÄ
ÏßÐÔ±í£¬¼´ÏÞÖÆÔÚ±íµÄÒ»¶Ë½øÐвåÈ롢ɾ³ýÔËË㡣ͨ³£²åÈ롢ɾ³ýµÄÒ»¶Ë³ ......

C/C++ÖеÄÈÕÆÚºÍʱ¼ä

תÔØÓÚÕâÀhttp://www.programfan.com/article/showarticle.asp?id=2798
²»Ì«¶®ÈçºÎ¶ÔÔËÓÃc++µÄʱ¼äº¯ÊýµÄÅóÓѶ࿴¿´°É¡£
*************************ÆÓËصķָîÏß**********************************
׫ÎÄ/ÖÜÏè
ͻ񻣼
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê ......

CÓïÑÔ»ù±¾¹¦½Ì³ÌϵÁÐ(3) ¿ìËٵĺ¯Êýµ÷ÓÃ

CÓïÑÔ»ù±¾¹¦½Ì³ÌϵÁÐ(3) - ¿ìËٵĺ¯Êýµ÷ÓÃ
ÎÒÓÖÀ´ÁË£¬½ñÌ쿲¿²º¯Êýµ÷ÓõÄÎÊÌâ¡£º¯ÊýÄÄÀﶼÓУ¬Ð¡µÄ³ÌÐòÒ»Á½¸öº¯Êý£¬´óµÄ³ÌÐò³É°ÙÉÏǧ¸öº¯Êý¡£¼´Ê¹ÔÚÓÎÏ·µÄ¹Ø¼üÑ­»·ÖУ¬µ÷Óü¸Ê®¸öº¯ÊýÒ²ÊǺܳ£¼ûµÄ¡£ËùÒÔº¯Êýµ÷ÓôúÂëµÄÖÊÁ¿£¬Ôںܴó³Ì¶ÈÉÏÓ°Ïì×ÅÓÎÏ·µÄÖÊÁ¿¡£
»¹ÊÇÏÈ˵×î»ù±¾µÄ´úÂë·ç¸ñÎÊÌâ¡£Ê×ÏÈ£¬¶ÔÓÚº¯ÊýµÄ²ÎÊý£¨ÌرðÊÇ ......

C/C++ÓïÑÔÖÐÖ¸ÕëµÄÒâÒå

¿´µ½Õâ¸öÃæÊÔÌâ,¹À¼ÆºÜ¶à¸ÕѧCÖ¸ÕëµÄͬѧ¶¼»á¸ã´í.
void GetMemory(char *p)
{
// ´«µÝ½øÀ´µÄµÄֵʹµÃ*p==NULL
// ÕâÀïÐ޸ĵÄÊÇÕâ¸öº¯ÊýÄÚµÄÁÙʱָÕë±äÁ¿pµÄÖµ
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
// ´«µÝ½øÈ¥µÄÊÇstrµÄÖµNULL
GetMemory(str);
// ÕâÀïstrÖ¸Õë² ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ