#include<stdio.h> #include<stdlib.h> #include<ctype.h> int fun() { int ch; int ret=0; while(isdigit(ch=getchar())) { ret=ret*10+ch-48; } ungetc(ch,stdin); return ret; } void fun1() { int ch; int ret=fun(); printf("%d\n",ret); ch=getchar(); putchar(ch); } void fun2() { FILE *fp=fopen("1.txt","r"); char ch=fgetc(fp); printf("%c\n",ch); ch=fgetc(fp); printf("%c\n",ch); fseek(fp,-2,SEEK_CUR);//当前 ch=fgetc(fp); printf("%c\n",ch); fseek(fp,-5,SEEK_END);//末尾 //rename("1.txt","22.txt"); //改文件名为22.txt 需要带后缀的全名 fclose(fp); //rename("1.txt","22.txt"); 关闭文件或者不关闭文件均可以实现改名字 printf("%c\n",ch); } void main() { fun1(); #if(1) fun2(); #endif }
file 文件操作
原创
©著作权归作者所有:来自51CTO博客作者文洲的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:小代码
下一篇:小代码 二进制位处理事情

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
操作文件File类方法
文件操作File.Copy(“source”, “targetFileName”, true);//文件拷贝,true表示当文
FileStream 文本文件 字符串