讀取檔案操作

2021-08-31 08:08:20 字數 803 閱讀 6540

//獲取路徑

nsstring *path=[[nsbundle mainbundle]pathforresource:@"file3" oftype:@"dmh"];

//nslog(@"path:%@",path);

//轉換

unsigned int lenofstrvalue = [path length];

char szvalue[lenofstrvalue + 1];

strcpy(szvalue, [path cstring]);

//printf("message:%s\n",szvalue);

file *wordfile=fopen(szvalue,"r");

byte *data=malloc(sizeof(byte) * length1);

if (wordfile == nil) else

}//獲取檔案長度

// 移到最後跳ol

// fseek(wordfile,0l,seek_end);

// 獲取檔案長度

// long t=ftell(wordfile);

// 移到開始跳offset

// fseek(wordfile, offset, seek_set);

// 獲取檔案長度,在這之前要移到檔案最後

// long tt=ftell(wordfile);

//讀取長度

int ass=fread(data,length1,1,wordfile);

//關閉檔案流

fclose(wordfile);

檔案操作之讀取檔案

檔案操作 檔案上傳 儲存log 系統函式 open file,mode,buffing,encoding 讀 open path filename,rt 返回值 stream 管道 container stream.read 讀取管道中的內容 注意 如果傳遞的path filename有誤,則會報錯...

PHP檔案讀取操作

fopen 函式檔案模式總結 fopen 函式 document server document root fp fopen document order.txt rb fclose fp 讀寫完畢之後,記得關閉檔案指標。fp fopen order.txt rb true 通過ftp或http開啟...

python檔案讀取操作

r 讀模式 w 寫模式 a 追加模式 b 二進位制模式 可新增到其他模式中使用 讀或者寫模式 可新增到其他模式中使用 read 方法 一次讀取檔案所有內容。a.txt檔案內容如下 hello,world 例項 f open a.txt r a f.read f.close print a 輸出 he...