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

c»ñÈ¡ÎļþµÄ´óСºÍÎļþÊôÐÔ¡¢Îļþ²éÕÒ

1 fseekÒÆ¶¯Ö¸Õë»ñÈ¡
#include <stdio.h>
#include <stdlib.h>
long filesize( FILE *fp )
{
    long int save_pos;
    long size_of_file;
    /* Save the current position. */
    save_pos = ftell( fp );
    /* Jump to the end of the file. */
    fseek( fp, 0L, SEEK_END );
    /* Get the end position. */
    size_of_file = ftell( fp );
    /* Jump back to the original position. */
    fseek( fp, save_pos, SEEK_SET );
    return( size_of_file );
}
int main( void )
{
    FILE *fp;
    fp = fopen( "aa.txt", "r" );
    if( fp != NULL ) {
        printf( "File size=%ld\n", filesize( fp ) );
        fclose( fp );
        return EXIT_SUCCESS;
    }
    return EXIT_FAILURE;
}
2 stat»ñÈ¡
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main( void )
{
struct stat buf;
if( stat( "file", &buf ) != -1 ) {
printf( "File size = %d\n", buf.st_size );
}
return EXIT_SUCCESS;
}
µ«ÊÇÊÇÓÐÇø±ðµÄ£¬Èç
²Î¿¼fseek()¡£
¡¡¡¡Í¨¹ýfseek()¡¢ftell()Á½¸öº¯Êý£¬ÎÒÃǾͿÉÒÔËæÒâ·ÃÎÊÎļþµÄÈκÎλÖÃÁË£¬ÏëÁËÏëºÃÏñ²Ù×÷Îļþ¾ÍÕâôeasy£¬ÊµÔÚҲûÓиü¶à¿É˵µÄÁË¡£¶ÔÁË£¬fseek()ºÍftell()´æÔÚÒ»¸öDZÔÚµÄÎÊÌâ¾ÍÊÇËûÃÇÏÞÖÆÎļþµÄ´óСֻÄÜÔÚlongÀàÐ͵ıíʾ·¶Î§ÒÔÄÚ£¬Ò²¾ÍÊÇ˵ͨ¹ýÕâÖÖ·½Ê½£¬Ö»ÄÜ´ò¿ª 2,000,000,000×Ö½ÚµÄÎļþ£¬²»¹ýÔÚ¾ø´ó¶àÊýÇé¿öÏÂËÆºõÒ²ÒѾ­¹»ÓÃÁË¡£Èç¹ûÐèÒª´ò¿ª¸ü´óµÄÎļþ£¬ÄãÐèÒªÓõ½fgetpos()¡¢ fsetpos()º¯ÊýÁË£¬ÄÇÊÇÁíÒ»¸öÃüÌâÁË¡£
#include <stdio.h>
#include <string.h>
int main()
{
    int  i;
    long k;
    char buf[100];
    long int save_pos;
    FILE *fp;
  


Ïà¹ØÎĵµ£º

C´úÂë¹æ·¶ÓëÔËÐÐʱ³¤·ÖÎöÄ£°å

/*****************************************************
Îļþ:main.c
¹¦ÄÜ:²âÊÔÔËÐÐʱ¼ä(C)!
×÷Õß:chinayaosir   QQ:44633197
¹¤¾ß:VC++6.0±àÒëOK!
ÈÕÆÚ:11/28/2009
´úÂëĿ¼:
//1.°üº¬Í·Îļþ
//2.mainÖ÷³ÌÐò
//²»Í¬µÄË㷨ʵÏÖµÄÐÔÄÜ,ÔËÐÐʱ¼äÏà²î·Ç³£´óµÄ!
ÐÞ¸ÄÁбí:
***************** ......

Cµ½»ã±àµÄÏêϸ½²½â

»ã±à½ÒÃØCÓïÑÔÖеIJÎÊý´«µÝÎÊÌâ[zz]
ÎÄÕÂ×÷Õߣºcook702
ºÜ¶àѧϰ»ã±àµÄÅóÓÑÏë±Ø¶ÔCÒ²±È½ÏÁ˽⣬ÒòΪÔÚµ±Ç°´óѧµÄ¿Î³ÌÌåϵÀËüºÜÓпÉÄܾÍÊÇÄã½Ó´¥µ½µÄµÚÒ»Ãűà³ÌÓïÑÔ¡£ÓÉÓÚ¶Ô¼ÆËã»úµÄÀí½â²»¹»£¬Ñ§Ï°Ê±±Ø¶¨»áÓö
µ½¸÷ÖÖÎÊÌâ¡£ÓÐЩÎÊÌâÊÇÄãͨ¹ý˼¿¼¾Í¿ÉÒÔ½â¾öµÄ£¬¶ø¸ü¶àµÄÎÊÌâÔòÊÇÄãÎÞ´Ó˼¿¼£¬¾ÍºÃÏñËüÌìÉú¾ÍÊÇÕâÑù£¬ÄãÖ»Ò ......

¸ß¿É¿¿ÐÔC³ÌÐòµÄ¼¸µãÒªÇó

Ò»¡¢¿ÉÖØÈ뺯Êý
1£©Ê²Ã´ÊÇ¿ÉÖØÈëÐÔ£¿
¿ÉÖØÈ루reentrant£©º¯Êý¿ÉÒÔÓɶàÓÚÒ»¸öÈÎÎñ²¢·¢Ê¹Ó㬶ø²»±Øµ£ÐÄÊý¾Ý´íÎó¡£Ïà·´£¬ ²»¿ÉÖØÈ루non-reentrant£©º¯Êý²»ÄÜÓɳ¬¹ýÒ»¸öÈÎÎñËù¹²Ïí£¬³ý·ÇÄÜÈ·±£º¯ÊýµÄ»¥³â£¨»òÕßʹÓÃÐźÅÁ¿£¬»òÕßÔÚ´úÂëµÄ¹Ø¼ü²¿·Ö½ûÓÃÖжϣ©¡£¿ÉÖØÈ뺯Êý¿ÉÒÔÔÚÈÎÒâʱ¿Ì±»Öжϣ¬ÉÔºóÔÙ¼ÌÐøÔËÐУ¬²»»á¶ªÊ§Êý¾Ý ......

C/C++Êý×éÃûÓëÖ¸ÕëÇø±ðÉî²ã̽Ë÷

C/C++Êý×éÃûÓëÖ¸ÕëÇø±ðÉî²ã̽Ë÷
 
×÷ÕߣºËᦻª e-mail:21cnbao_AT_21cn.com [AT -> @]
1. ÒýÑÔ
Ö¸ÕëÊÇC/C++ÓïÑÔµÄÌØÉ«£¬¶øÊý×éÃûÓëÖ¸ÕëÓÐÌ«¶àµÄÏàËÆ£¬ÉõÖÁºÜ¶àʱºò£¬Êý×éÃû¿ÉÒÔ×÷ΪָÕëʹÓá£ÓÚÊǺõ£¬ºÜ¶à
³ÌÐòÉè¼ÆÕ߾ͱ»¸ãºýÍ¿ÁË¡£¶øÐí¶àµÄ´óѧÀÏʦ£¬ËûÃÇÔÚC ÓïÑԵĽÌѧ¹ý³ÌÖÐÒ²´íÎóµÃ¸øÑ§Éú½²½â£º“Êý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ