這是Herr Deng桑的教學blog,主要處理作業與班導事務,另外還有數位小品。
fopen:開啟檔案或URL int fopen (string filename, string mode [, int use_include_path])fseek:移動檔案指標 int fseek (int fp, int offset [, int whence])ftell:取得檔案指標讀/寫的位置 int ftell (int fp)rewind:重置檔案指標 int rewind (int fp)fclose:關閉已開啟的檔案指標 int fclose (int fp)
#include int main(void) { FILE *fp; char N[5]; printf("請輸入檔名:"); gets(N); if(fp = fopen(N , "w")) == NULL){ printf("\a無法開啟檔案。 \n");}else { /* 從檔案寫入資料 */ fclose(fp) ; /* 關閉檔案 */ } return (0) ; }
fopen 語法 : fopen ( const char * filename, const char * mode ); 開啟檔案 fclose 語法: int fclose(int fp); 關閉已打開的文件。ftell 語法:long int ftell ( FILE * stream ); 取得檔案指標讀/寫的位置fseek 語法:int fseek ( FILE * stream, long int offset, int origin ); 移動檔案指標rewind 語法:void rewind ( FILE * stream ); 重置檔案指標
fopen 開啟檔案或URL FILE * fopen ( const char * filename, const char * mode );fseek 移動檔案指標int fseek ( FILE * stream, long int offset, int origin );ftell 取得檔案指標讀/寫的位置long int ftell ( FILE * stream ); rewind 重置檔案指標void rewind ( FILE * stream );
ftell :long int ftell ( FILE * stream ); 取得檔案指標讀/寫的位置fseek :int fseek ( FILE * stream, long int offset, int origin ); 移動檔案指標rewind :void rewind ( FILE * stream ); 重置檔案指標fopen: fopen ( const char * filename, const char * mode ); 開啟檔案fclose: int fclose(int fp);關閉已打開的文件
fopen:開啟檔案或URLFILE * fopen ( const char * filename, const char * mode );fseek:移動檔案指標int fseek ( FILE * stream, long int offset, int origin );ftell:取得檔案指標讀/寫的位置long int ftell ( FILE * stream ); rewind:重置檔案指標void rewind ( FILE * stream );fclose:關閉已開啟的檔案指標int fclose ( FILE * stream );
fopen : 以唯讀或唯寫的方式開起檔案資料。fseek : 將檔案資料的指標移到指定偏移位元上。ftell : 傳回檔案的指標偏移位元值,當發生錯誤時,傳回false值。檔案指標必須是有效的,且使用fopen函式開啟才能作用。rewind : 重置檔案的讀寫位置指標到檔案的開頭出,發生錯誤則傳回0。檔案指標必須是有效的,且使用fopen函式開啟的檔案。fclose : 關閉以fopen開啟的檔案資料。
HTML 編輯器
fopen:開啟檔案或URL
回覆刪除int fopen (string filename, string mode [, int use_include_path])
fseek:移動檔案指標
int fseek (int fp, int offset [, int whence])
ftell:取得檔案指標讀/寫的位置
int ftell (int fp)
rewind:重置檔案指標
int rewind (int fp)
fclose:關閉已開啟的檔案指標
int fclose (int fp)
#include
回覆刪除int main(void)
{
FILE *fp; char N[5];
printf("請輸入檔名:");
gets(N);
if(fp = fopen(N , "w")) == NULL){
printf("\a無法開啟檔案。 \n");
}else {
/* 從檔案寫入資料 */
fclose(fp) ; /* 關閉檔案 */
}
return (0) ;
}
fopen 語法 : fopen ( const char * filename, const char * mode ); 開啟檔案
回覆刪除fclose 語法: int fclose(int fp); 關閉已打開的文件。
ftell 語法:long int ftell ( FILE * stream ); 取得檔案指標讀/寫的位置
fseek 語法:int fseek ( FILE * stream, long int offset, int origin ); 移動檔案指標
rewind 語法:void rewind ( FILE * stream ); 重置檔案指標
fopen 開啟檔案或URL
回覆刪除FILE * fopen ( const char * filename, const char * mode );
fseek 移動檔案指標
int fseek ( FILE * stream, long int offset, int origin );
ftell 取得檔案指標讀/寫的位置
long int ftell ( FILE * stream );
rewind 重置檔案指標
void rewind ( FILE * stream );
ftell :
回覆刪除long int ftell
( FILE * stream );
取得檔案指標讀/寫的位置
fseek :
int fseek
( FILE * stream, long int offset, int origin );
移動檔案指標
rewind :
void rewind
( FILE * stream );
重置檔案指標
fopen:
fopen
( const char * filename, const char * mode );
開啟檔案
fclose: int fclose(int fp);
關閉已打開的文件
fopen:開啟檔案或URL
回覆刪除FILE * fopen ( const char * filename, const char * mode );
fseek:移動檔案指標
int fseek ( FILE * stream, long int offset, int origin );
ftell:取得檔案指標讀/寫的位置
long int ftell ( FILE * stream );
rewind:重置檔案指標
void rewind ( FILE * stream );
fclose:關閉已開啟的檔案指標
int fclose ( FILE * stream );
fopen : 以唯讀或唯寫的方式開起檔案資料。
回覆刪除fseek : 將檔案資料的指標移到指定偏移位元上。
ftell : 傳回檔案的指標偏移位元值,當發生錯誤時,傳回false值。檔案指標必須是有效的,且使用fopen函式開啟才能作用。
rewind : 重置檔案的讀寫位置指標到檔案的開頭出,發生錯誤則傳回0。檔案指標必須是有效的,且使用fopen函式開啟的檔案。
fclose : 關閉以fopen開啟的檔案資料。