
文件操作
xiongping_
这个作者很懒,什么都没留下…
展开
-
fopen与open区别
头文件:#include fopen()是一个常用的函数,用来以指定的方式打开文件,其原型为: FILE * fopen(const char * path, const char * mode);【参数】path为包含了路径的文件名,mode为文件打开方式。mode有以下几种方式:打开方式说明r以只读方式打开文件,该文原创 2015-04-21 09:37:07 · 721 阅读 · 0 评论 -
文件结构体之struct stat
在使用这个结构体和方法时,需要引入:struct stat这个结构体是用来描述一个linux系统文件系统中的文件属性的结构。可以有两种方法来获取一个文件的属性:1、通过路径:int stat(const char *path, struct stat *buf);int lstat(const char *path,struct stat *转载 2015-04-21 09:00:00 · 471 阅读 · 0 评论 -
文件大小和文件长度的区别
1.获取文件大小:S64 OsalFileSizeGet(char *apFile){ struct stat buf; if(stat(apFile,&buf) return 0; else return buf.st_size;}2.获取文件长度:S32 OsalFileLenGet(FILE *pFil原创 2015-04-21 09:17:46 · 3327 阅读 · 0 评论 -
文件函数ftruncate
ftruncate(改变文件大小)相关函数 open,truncate表头文件 #include定义函数 int ftruncate(int fd,off_t length);函数说明ftruncate()会将参数fd指定的文件大小改为参数length指定的大小。参数fd为已打开的文件描述词,而且必须是以写入模式打开的文件。如果原来的文件大小比参数length大,则原创 2015-04-21 09:26:34 · 494 阅读 · 0 评论 -
文件函数之fscanf和fprintf
fscanf简述:C语言中基本的文件操作功 能:This function is just like scanf, except that the input is read from the stream stream instead of stdin. 从一个流中执行格式化输入,fscanf遇到空格和换行时结束,注意空格时也结束。这与fgets有区别,fgets遇到空格不结原创 2015-04-21 11:36:57 · 622 阅读 · 0 评论