第五章文件内容操作(编辑修改稿)内容摘要:

♦ include ♦ include ♦ void main() { ♦ FILE* fp。 ♦ char s[50]。 ♦ char str[] = hello, this is a test for chapter 5!。 ♦ int i。 ♦ fp=fopen(“/tmp/hello,w+)。 ♦ i = fwrite(str,1,sizeof(str),fp)。 //续 ♦ fseek(fp,20,SEEK_SET)。 ♦ i = fread(s,5,10,fp)。 ♦ printf(%s\n %d \n,s,i)。 ♦ fseek(fp,25,SEEK_END)。 ♦ i = fread(s,5,6,fp)。 ♦ printf(%s\n %d \n,s,i)。 ♦ fclose(fp)。 ♦ } opendir函数 表头文件 includesys/ include 函数原型 DIR * opendir(const char * name)。 函数功能 打开目录 函数输入 打开参数 name指定的目录,并返回 DIR*形态的目录流 返回值 成功则返回 DIR* 型态的目录流,打开失败则返回 NULL。 相关函数 open, readdir, closedir readdir函数 表头文件 includesys/ include 函数原型 struct dirent * readdir(DIR * dir)。 函数功能 读取目录 函数输入 返回参数 dir目录流的下个目录进入点,结构 dirent定义为struct dirent { ino_t d_ino。 ff_t d_off。 signed short int d_reclen。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。