Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÓïÑÔλÔËËã

Ç°Ãæ½éÉܵĸ÷ÖÖÔËË㶼ÊÇÒÔ×Ö½Ú×÷Ϊ×î»ù±¾Î»½øÐеġ£ µ«Ôںܶàϵͳ³ÌÐòÖг£ÒªÇóÔÚλ(bit)Ò»¼¶½øÐÐÔËËã»ò´¦Àí¡££ÃÓïÑÔÌṩÁËλÔËËãµÄ¹¦ÄÜ£¬ÕâʹµÃ£ÃÓïÑÔÒ²ÄÜÏñ»ã±àÓïÑÔÒ»ÑùÓÃÀ´±àдϵͳ³ÌÐò¡£
12.1 λÔËËã·û£ÃÓïÑÔÌṩÁËÁùÖÖλÔËËã·û£º
    &          °´ ......

CÓïÑÔÎļþ

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

ÉîÈëÀí½âextern "C"

Ò»¡¢´ÓCÓëC++±àÒëÁ¬½Ó·½Ê½ÉîÈëÀí½âextern "C"
<1>.CºÍC++¶Ôº¯ÊýµÄ´¦Àí·½Ê½ÊDz»Í¬µÄ.±»extern "C"ÐÞÊεıäÁ¿ºÍº¯ÊýÊÇ°´ÕÕCÓïÑÔ·½Ê½±àÒëºÍÁ¬½ÓµÄ.extern "C"ÓÃÓÚʵÏÖC++ÓëC¼°ÆäËüÓïÑԵĻìºÏ±à³Ì¡£
<2>.δ¼Óextern “C”ÉùÃ÷ʱµÄ±àÒ뷽ʽ
Ê×ÏÈ¿´¿´C++ÖжÔÀàËÆCµÄº¯ÊýÊÇÔõÑù±àÒëµÄ¡£
×÷ΪһÖÖÃæÏò ......

ǶÈëʽ¿ª·¢£­CÓïÑÔÃæÊÔÌâ(¶þ)

11¡¢ÏÂÃæµÄ´úÂëÊä³öÊÇʲô£¬ÎªÊ²Ã´£¿
Void foo(void)
{
unsigned int a = 6;
int b = -20;
(a+b > 6) £¿puts("> 6") : puts("<= 6");
}
²»¹ÜÈçºÎ£¬ÕâÎÞ·ûºÅÕûÐÍÎÊÌâµÄ´ð°¸ÊÇÊä³öÊÇ“>6”¡£Ô­ÒòÊǵ±±í´ïʽÖдæÔÚÓзûºÅÀàÐͺÍÎÞ·ûºÅÀàÐÍʱËùÓеIJÙ×÷Êý¶¼×Ô¶¯×ª»»ÎªÎÞ·ûºÅÀàÐÍ¡£Òò´Ë-20±ä³ÉÁËÒ»¸ ......

ÈçºÎʹC£¬C++±àÒëÆ÷¶¼¿ÉÒÔµ÷ÓÃCдµÄDLL

    ÓÉÓÚC++±àÒëÆ÷ÐèÒªÖ§³Öº¯ÊýµÄÖØÔØ£¬»á¸Ä±äº¯ÊýµÄÃû³Æ£¬Óë±ê×¼CÖк¯ÊýÃû³Æ²»Í¬¡£È»¶ødllµÄµ¼³öº¯Êýͨ³£ÊDZê×¼C¶¨ÒåµÄ£¬Èñê×¼C±àдµÄdllº¯Êý¶¨ÒåÔÚCºÍC++±àÒëÆ÷϶¼ÄܱàÒëͨ¹ý£¬Í¨³£»áʹÓÃÒÔϵĸñʽ£º£¨Õâ¸ö¸ñʽÔںܶà³ÉÊìµÄ´úÂëÖкܳ£¼û£©
#ifdef __cplusplus extern "C" 

#endif
// ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ