`
咖啡动力
  • 浏览: 435127 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

读取文件操作

 
阅读更多
//获取路径
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) {
NSLog(@"can not open this file .\n");
exit(0);
}else {
if (offset>0) {
//跳过offset这么长,0表示从开始跳
fseeko(wordFile,offset,0);
}

}
//获取文件长度
//            移到最后跳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);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics