c»ñµÃÎļþ´óС
1.MFCÖеķ½·¨£º(C++)
CFileStatus status;
CFile::GetStatus("D:\\test.txt",status);
long lSizeOfFile;
lSizeOfFile = status.m_size;
lSizeOfFileµÄÖµ¾ÍÊÇD:\\test.txtÎļþµÄ´óС
2.±ê×¼C»ñµÃÎļþ´óСµÄ5ÖÖ·½·¨
(×¢Ò⣺"__FILE__"Ö¸µÄÊǵ±Ç°Îļþ£¬Äã¿ÉÒÔ¸ÄΪÓÐЧ·¾¶µÄÄ¿±êÎļþ£¬±ÈÈç"D:\\test.txt"£©
#include "stdafx.h"
#include "stdio.h"
#include <sys/stat.h>
#include <io.h>
#include <FCNTL.H>
int getfilesize()
{
int iresult;
struct _stat buf;
iresult = _stat(__FILE__,&buf);
if(iresult == 0)
{
return buf.st_size;
}
return NULL;
}
int getfilesize01()
{
int fp;
fp=_open(__FILE__,_O_RDONLY);
if(fp==-1)
return NULL;
return _filelength(fp);
//return NULL;
}
int getfilesize02()
{
int fp;
fp=_open(__FILE__,_O_RDONLY);
if(fp==-1)
return NULL;
return _lseek(fp,0,SEEK_END);
//return NULL;
}
int getfilesize03()
{
int fp;
fp=_open(__FILE__,_O_RDONLY);
if(fp==-1)
return NULL;
return _lseek(fp,0,SEEK_END);
//return NULL;
}
int getfilesize04()
{
FILE *fp;
if((fp=fopen(__FILE__,"r"))==NULL)
return 0;
fseek(fp,0,SEEK_END);
return ftell(fp); //return NULL;
}
int getfilesize05()
{
FILE *fp;
char str[1];
if((fp=fopen(__FILE__,"rb"))==NULL)
return 0;
for(int i = 0;!feof(fp);i++)
{
fread(&str,1,1,fp);
}
return i - 1; //return NULL;
}
int main(int argc, char* argv[])
{
printf("getfilesize()=%d\n",getfilesize());
printf("getfilesize01()=%d\n",getfilesize01());
printf("getfilesize02()=%d\n",getfilesize02());
printf("getfilesize03()=%d\n",getfilesize03());
printf("getfilesize04()=%d\n",getfilesize04());
printf("getfilesize05()=%d\n",getfilesize05());
return 0;
}
Ïà¹ØÎĵµ£º
1.1= Óë ==
Àý1£º
±¾ÀýÖÐÑ»·Óï¾äµÄ±¾ÒâÊÇÌø¹ýÎļþÖеĿոñ·û¡¢ÖƱí·û¡¢»»Ðзû
while(c=''||c=='\t'||c=='\n')
c=getc(f);
c= ''||c=='\t'||c=='\n'
ËÀÑ»·
Àý2£º
if((filedesc==open(argv[i],0))<0)
error();
ÓÀÔ¶²»»á±»µ÷ÓÃ
1.2 & ºÍ | ²»Í¬ÓÚ&& ºÍ||
1.3 CÓ ......
º¯ÊýÃû: abort
¹¦ ÄÜ: Òì³£ÖÕÖ¹Ò»¸ö½ø³Ì
ÓÃ ·¨: void abort(void);
³ÌÐòÀý:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Calling abort()\n");
abort();
return 0; /* This is never reached */
}
......
ÌâÄ¿£ºÊäÈëÈý¸ö×Ö·û´®a£¬bºÍc£¬½«aÖÐbµÄµÚÒ»´Î³öÏÖÌ滻Ϊc¡£
´úÂ룺
#include <iostream.h>
#include <string.h>
/*×Ö·û´®Ìæ»»£¬µÚÒ»¸ö²ÎÊýΪԴ®£¬µÚ¶þ¸ö²ÎÊýΪҪƥÅäµÄ×Ó´®
µÚÈý¸ö²ÎÊýΪҪÌæ»»µÄµÚÒ»¸ö×Ó´®Öаüº¬µÚ¶þ¸ö×Ó´®µÄ²¿·Ö*/
char *strReplace(char *str1,char *str2,char *str3);
void main() ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. setvectº¯Êý
setvectº¯ÊýµÄ¹¦ÄÜÊÇÉèÖÃÖжÏʸÁ¿Èë¿Ú£¬ÆäÓ÷¨Îª£ºvoid setvect(int intr_num, void interrupt(*isr)());³ÌÐòʵÀýÈçÏ£º
#include <st ......
º¯ÊýÃûÓ뺯ÊýÖ¸Õë
º¯Êý´æ·ÅÔÚÄÚ´æµÄ´úÂëÇøÓòÄÚ£¬ËüÃÇͬÑùÓеØÖ·£¬ÎÒÃÇÈçºÎÄÜ»ñµÃº¯ÊýµÄµØÖ·ÄØ£¿
Èç¹ûÎÒÃÇÓÐÒ»¸öint test(int a)µÄº¯Êý£¬ÄÇô£¬ËüµÄµØÖ·¾ÍÊǺ¯ÊýµÄÃû×Ö£¬ÕâÒ»µãÈçͬÊý×éÒ»Ñù£¬Êý×éµÄÃû×Ö¾ÍÊÇÊý×éµÄÆðʼµØÖ·¡£
Ò» ͨ³£µÄº¯Êýµ÷ÓÃ
Ò»¸öͨ³£µÄº¯Êýµ÷ÓõÄÀý×Ó ......