線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1120
推到 Plurk!
推到 Facebook!

這是代表什麼意思??

尚未結案
c9206010
一般會員


發表:1
回覆:1
積分:0
註冊:2005-04-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-22 01:38:39 IP:220.141.xxx.xxx 未訂閱
以下是程式中的某段 long file_size( char *name ) { long eof_ftell; FILE *file; file=fopen(name,"r"); if(file == NULL) return(0L); fseek(file, 0L, SEEK_END);//我想請問一下這行是什麼意思?? eof_ftell = ftell(file); fclose(file); return(eof_ftell); }
ccobj
一般會員


發表:6
回覆:27
積分:21
註冊:2003-12-02

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-04-22 07:49:55 IP:218.172.xxx.xxx 未訂閱
把檔案指標設定在結尾
mier_tt
一般會員


發表:18
回覆:43
積分:12
註冊:2004-12-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-04-22 08:35:30 IP:59.33.xxx.xxx 未訂閱
以下是msdn上的關於這個函式的解釋.    fseek Moves the file pointer to a specified location.    int fseek(     FILE *stream,    long offset,    int origin  ); Parameters stream  Pointer to FILE structure.  offset  Number of bytes from origin.  origin  Initial position.  Return Value If successful, fseek returns 0. Otherwise, it returns a nonzero value. On devices incapable of seeking, the return value is undefined.    Remarks The fseek function moves the file pointer (if any) associated with stream to a new location that is offset bytes from origin. The next operation on the stream takes place at the new location. On a stream open for update, the next operation can be either a read or a write. The argument origin must be one of the following constants, defined in STDIO.H:     SEEK_CUR  Current position of file pointer.  SEEK_END  End of file.  SEEK_SET  Beginning of file.  You can use fseek to reposition the pointer anywhere in a file. The pointer can also be positioned beyond the end of the file. fseek clears the end-of-file indicator and negates the effect of any prior ungetc calls against stream.    When a file is opened for appending data, the current file position is determined by the last I/O operation, not by where the next write would occur. If no I/O operation has yet occurred on a file opened for appending, the file position is the start of the file.     For streams opened in text mode, fseek has limited use, because carriage return–linefeed translations can cause fseek to produce unexpected results. The only fseek operations guaranteed to work on streams opened in text mode are:     Seeking with an offset of 0 relative to any of the origin values.  Seeking from the beginning of the file with an offset value returned from a call to ftell.  Also in text mode, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading/writing, fopen and all related routines check for a CTRL+Z at the end of the file and remove it if possible. This is done because using fseek and ftell to move within a file that ends with a CTRL+Z may cause fseek to behave improperly near the end of the file.     Requirements Function Required header Compatibility  fseek  ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP For additional compatibility information, see Compatibility in the Introduction. Libraries All versions of the C run-time libraries. Example // crt_fseek.c /* This program opens the file FSEEK.OUT and * moves the pointer to the file's beginning. */ #include int main( void ) { FILE *stream; char line[81]; int result; stream = fopen( "fseek.out", "w " ); if( stream == NULL ) printf( "The file fseek.out was not opened\n" ); else { fprintf( stream, "The fseek begins here: " "This is the file 'fseek.out'.\n" ); result = fseek( stream, 23L, SEEK_SET); if( result ) perror( "Fseek failed" ); else { printf( "File pointer is set to middle of first line.\n" ); fgets( line, 80, stream ); printf( "%s", line ); } fclose( stream ); } } Output File pointer is set to middle of first line. This is the file 'fseek.out'.
c9206010
一般會員


發表:1
回覆:1
積分:0
註冊:2005-04-22

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-04-22 11:32:47 IP:218.175.xxx.xxx 未訂閱
嗯嗯~謝謝執導 那 fseek(file, 0L, SEEK_END);//0L 這個是到表什麼呢?0數字?L?? 搞不懂!!!
暗黑破壞神
版主


發表:9
回覆:2301
積分:1627
註冊:2004-10-04

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-04-22 12:14:56 IP:221.169.xxx.xxx 未訂閱
整段是在說要取得檔案的長度。 你該自己去查查 fseek 怎麼用吧。 在你的 c Builder 中打一下 fseek 然後按一下 CTRL-F1 可以得到你想要的東西。 看不懂英文就要翻字典囉。 你這樣無法把C學好囉。 http://www.mcu51.com/list.asp?id=1588 想想別人怎麼學,我們有這麼用心嗎? 憂心啊~~~~~~
系統時間:2024-05-19 18:18:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!