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

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;
}


Ïà¹ØÎĵµ£º

C/C++——С±à̸CÓïÑÔº¯ÊýÄÇЩÊÂ(20)

C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
 
1.     setallpalletteº¯Êý
setallpalletteº¯ÊýµÄ¹¦ÄÜÊÇ°´Ö¸¶¨·½Ê½¸Ä±äËùÓеĵ÷É«°åÑÕÉ«£¬ÆäÓ÷¨Îª£ºvoid far setallpallette(struct palette, fa ......

C/C++ style

 #include <stdio.h>
int main()
{
char *str[] = {"welcome", "to", "fortemedia", "nanjing"};
char **p = str + 1;
str[0] = ( *p++ ) + 2;
str[1] = * ( p + 1 );
str[2] = p[1] + 3;
str[3] = p[0] + ( str[2] - str[1] );
printf ( "%s\n", str[0] );
printf ( ......

c±à³ÌÔÚlinuxϲÅÓÐÒâÒå

 ½ñÌìΪÁ˸ø¶¥Ç¶±­×ö×¼±¸Óֻص½linuxÏ¿ªÊ¼c±à³ÌÁË¡£¸Õ¿ªÊ¼ÊÇÁ·Ï°Ð´Ò»¸öÓë¾ØÕó±ä»»ÓйصijÌÐò£¬ÎªÁ˽Úʡʱ¼äÓÐÒ»¸öº¯ÊýÄ£¿éÊÇÖ±½ÓÓõÄÒÔÇ°ÔÚwindowsϱà³ÌʱËùʹÓõġ£½á¹ûÔÚlinuxϱàÒëÍêÔËÐÐÖ®ºóºÜ¿ì¾Í±ÀÀ£ÁË£¬ÓÉÓÚµ÷ÊÔˮƽ²»¸ßŪÁ˺ܾÃÒ²²»Öªµ½ÎÊÌâ³öÔÚÄÄÀï¡£ÕýÔÚ°Ù˼²»µÃÆä½âʱºöÈ»×¢Òâµ½£¨µ±È»²»ÊÇ×Ô¼ºµ÷ÊÔ³öÀ´µÄ ......

ʹÓÃKeil Cµ÷ÊÔijϵͳʱ»ýÀÛµÄһЩ¾­Ñé

 Ê¹ÓÃKeil Cµ÷ÊÔijϵͳʱ»ýÀÛµÄһЩ¾­Ñé
1¡¢ÔÚWindows2000ÏÂÃ棬ÎÒÃÇ¿ÉÒÔ°Ñ×ÖÌåÉèÖÃΪCourier£¬ÕâÑù¾Í¿ÉÒÔÏÔʾÕý³£¡£
2¡¢µ±Ê¹ÓÃÓÐƬÍâÄÚ´æµÄMCU£¨ÈçW77E58£¬ËüÓÐ1KƬÍâÄڴ棩µÄʱºò£¬¿Ï¶¨ÒªÉèÖñê־룬²¢ÇÒ±àÒ뷽ʽҪѡÔñ´óģʽ£¬·ñÔò»á³ö´í¡£
3¡¢µ±Ê¹ÓÃKeil C¸ú×Ù³ÌÐòÔËÐÐ״̬µÄʱºò£¬Òª°ÑÒýÆðWarningµÄÓï¾äÆÁ±Î£ ......

C/C++³ÌÐòԱӦƸ³£¼ûÃæÊÔÌâÉîÈëÆÊÎö

ת×Ô£ºhttp://dev.yesky.com/471/2306471.shtml
1.ÒýÑÔ
¡¡¡¡±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº­¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û¡£
¡¡¡¡Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄst ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ