C/C++Îļþ²Ù×÷
c/C++Îļþ²Ù×÷
Èí¼þ¿ª·¢ 2009-03-12 16:22 ÔĶÁ18 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
»ùÓÚCµÄÎļþ²Ù×÷
¡¡¡¡ÔÚANSI CÖУ¬¶ÔÎļþµÄ²Ù×÷·ÖΪÁ½ÖÖ·½Ê½£¬¼´Á÷ʽÎļþ²Ù×÷ºÍI/OÎļþ²Ù×÷£¬ÏÂÃæ¾Í·Ö±ð½éÉÜÖ®¡£
Ò»¡¢Á÷ʽÎļþ²Ù×÷
¡¡¡¡ÕâÖÖ·½Ê½µÄÎļþ²Ù×÷ÓÐÒ»¸öÖØÒªµÄ½á¹¹FILE£¬FILEÔÚstdio.hÖж¨ÒåÈçÏ£º
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 */
¡¡¡¡FILEÕâ¸ö½á¹¹°üº¬ÁËÎļþ²Ù×÷µÄ»ù±¾ÊôÐÔ£¬¶ÔÎļþµÄ²Ù×÷¶¼ÒªÍ¨¹ýÕâ¸ö½á¹¹µÄÖ¸ÕëÀ´½øÐУ¬´ËÖÖÎļþ²Ù×÷³£Óõĺ¯Êý¼ûÏÂ±í º¯Êý ¹¦ÄÜ
fopen() ´ò¿ªÁ÷
fclose() ¹Ø±ÕÁ÷
fputc() дһ¸ö×Ö·ûµ½Á÷ÖÐ
fgetc() ´ÓÁ÷ÖжÁÒ»¸ö×Ö·û
fseek() ÔÚÁ÷Öж¨Î»µ½Ö¸¶¨µÄ×Ö·û
fputs() д×Ö·û´®µ½Á÷
fgets() ´ÓÁ÷ÖжÁÒ»ÐлòÖ¸¶¨¸ö×Ö·û
fprintf() °´¸ñʽÊä³öµ½Á÷
fscanf() ´ÓÁ÷Öа´¸ñʽ¶ÁÈ¡
feof() µ½´ïÎļþβʱ·µ»ØÕæÖµ
ferror() ·¢Éú´íÎóʱ·µ»ØÆäÖµ
rewind() ¸´Î»Îļþ¶¨Î»Æ÷µ½Îļþ¿ªÊ¼´¦
remove() ɾ³ýÎļþ
fread() ´ÓÁ÷ÖжÁÖ¸¶¨¸öÊýµÄ×Ö·û
fwrite() ÏòÁ÷ÖÐдָ¶¨¸öÊýµÄ×Ö·û
tmpfile() Éú³ÉÒ»¸öÁÙʱÎļþÁ÷
tmpnam() Éú³ÉÒ»¸öΨһµÄÎļþÃû
¡¡¡¡ÏÂÃæ¾Í½éÉÜÒ»ÏÂÕâЩº¯Êý
1.fopen()
¡¡¡¡fopenµÄÔÐÍÊÇ£ºFILE *fopen(const char *filename,const char *mode)£¬fopenʵÏÖÈý¸ö¹¦ÄÜ
ΪʹÓöø´ò¿ªÒ»¸öÁ÷
°ÑÒ»¸öÎļþºÍ´ËÁ÷ÏàÁ¬½Ó
¸ø´ËÁ÷·µ»ØÒ»¸öFILRÖ¸Õë
²ÎÊýfilenameÖ¸ÏòÒª´ò¿ªµÄÎļþÃû£¬mode±íʾ´ò¿ª×´Ì¬µÄ×Ö·û´®£¬ÆäÈ¡ÖµÈçϱí
×Ö·û´® º¬Òå
"r" ÒÔÖ»¶Á·½Ê½´ò¿ªÎļþ
"w" ÒÔֻд·½Ê½´ò¿ªÎļþ
"a" ÒÔ×·¼Ó·½Ê½´ò¿ªÎļþ
"r+" ÒÔ¶Á/д·½Ê½´ò¿ªÎļþ£¬ÈçÎÞÎļþ³ö´í
"w+" ÒÔ¶Á/д·½Ê½´ò¿ªÎļþ£¬ÈçÎÞÎļþÉú³ÉÐÂÎļþ
¡¡¡¡Ò»
Ïà¹ØÎĵµ£º
Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸еģ¬»î»î»î£¡
&n ......
ÓдÎÒ»¸öͬÊÂÎÊÎÒ
swc ^= swc;
ÊÇʲôÒâ˼,ÎÒÒ²²»ÖªµÀ,²éÁËÏÂ,Òâ˼Ӧ¸ÃÊǽ«swc±äÁ¿Çå0£¬ÒÉ»óµÄÊÇΪʲô¾Í²»ÄÜд³É swc = 0; ÄØ?²»Ã÷°×
˳±ã¼Ç¼ÏÂÆäËûµÄ²Ù×÷,Åöµ½ÐµÄÔÙ×·¼Ó:
swc = ~swc; //±äÁ¿È¡·´ ......
̸̸CÓïÑÔµÄmalloc()ºÍfree()
Ò»¡¢malloc()ºÍfree()µÄ»ù±¾¸ÅÄîÒÔ¼°»ù±¾Ó÷¨£º
1¡¢º¯ÊýÔÐͼ°ËµÃ÷£º
void *malloc(long NumBytes)£º¸Ãº¯Êý·ÖÅäÁËNumBytes¸ö×Ö½Ú£¬²¢·µ»ØÁËÖ¸ÏòÕâ¿éÄÚ´æµÄÖ¸Õë¡£Èç¹û·ÖÅäʧ°Ü£¬Ôò·µ»ØÒ»¸ö¿ÕÖ¸Õ루NULL£©¡£
¹ØÓÚ·ÖÅäʧ°ÜµÄÔÒò£¬Ó¦¸ÃÓжàÖÖ£¬±ÈÈç˵¿Õ¼ä²»×ã¾ÍÊÇÒ»ÖÖ¡£
void free(void *Fir ......
ÉÏ´Î×ܽáÁËC++£¨ÃæÏò¶ÔÏó£©Éè¼ÆµÄºËÐÄ˼Ï룬²¢ÇÒÀý¾ÙÁËʹÓÃÀàÄ£ÐÍÀ´Ìæ´úifºÍswitchµÄÒ»ÖÖ½ÏΪµäÐ͵ÄÇé¿ö¡£ÏÂÃæÏëÀ´Ì¸Ì¸C++ÔÚ±àÂë·½ÃæµÄÌص㡣
ÔںܶྵäµÄC++½Ì³ÌÖж¼ÓÐÒ»¸ö½¨Ò飺Ӧ¾¡Á¿Ê¹Óû§´úÂ루¿âµÄʹÓÃÕߣ©¿´ÆðÀ´¶ÌС¶ø¼òµ¥¡£°´ÕÕ³£Ê¶£¬¼òµ¥µÄ´úÂëͨ³£Òª±È´ó¶ÎµÄ´úÂëºÃÀí½â£¬¶øÓû§´úÂëͨ³£ÊµÏÖµÄÊÇ×îÉϲãµÄ¹¦ÄÜ»òÕ ......
C/C++¹Ø¼ü×Östatic,const,inline,define,typedef
document.body.oncopy = function() {
if (window.clipboardData) {
setTimeout(function() {
......