取个标题想半天
luojingqing
全部博文(68)
人生感悟(3)
java(24)
asp(0)
2011年(3)
2010年(30)
2009年(17)
2008年(18)
浪花小雨
60182626
sjf0115
bbn9435
zhoubihu
superdav
風邪帝炎
winyee
hzhj727
分类: C/C++
2008-03-14 14:54:21
#include < stdio.h > main() {FILE *fp; char ch,filename[10]; scanf("%s",filename); if((fp=fopen(filename,"w"))==NULL) {printf("cannot open file\n"); exit(0); } ch=getchar(); while(ch!='#') { fputc(ch,fp),putchar(ch); ch=getchar(); } fclose(fp); }
file1.c? (输入磁盘文件名) computer and c#? (输入一个字符串) computer and c
#include < stdio.h > main() {FILE *in,*out; char ch,infile[10],outfile[10]; printf("Enter the infile name:\n"); scanf("%s",infile); printf("Enter the outfile name:\n"); scanf("%s",outfile); if((in=fopen(infile,"r"))==NULL) {printf("cannot open infile\n"); exit(0); } if((out=fopen(outfile,"w"))==NULL) {printf("cannot open outfile\n"); exit(0); } while(!feof(in))fputc(fgetc(in),out); fclose(in); fclose(out); }
Enter the infile name: file1.c?(输入原有磁盘文件名) Enter the outfile name: file2.c?(输入新复制的磁盘文件名)
#include < stdio.h > struct student_type { char name[10]; int num; int age; char sex; }stud[10] main() {int i; FILE *fp; if((fp=fopen("stud_dat","rb"))==NULL; { printf("cannot open file\n"); exit(0); } for(i=0;i<10;i+=2) { fseek(fp,i*sizeof(struct student_type),0); fread(&stud[i],sizeof(struct student_type),1,fp); printf("%s%d%d%c\n",stud[i].name,stud[i].num, stud[i].age,stud[i].sex); } fclose(fp); }
上一篇:VC 常见问题百问
下一篇:网站按钮问题
chinaunix网友2008-04-07 10:00:03
谢谢. 真不错..
登录 注册