c语言文件操作编程题

不知道你要什么?
例子:
/**************************************************/
/* 文件的字符形式读取与存储和字符串形式的读取与存储 */
/**************************************************/

/*读一个字符*/
#include "stdio.h"
#include "string.h"
main(){
FILE *fp;
char c;
if((fp=fopen("s.c","r"))==NULL){
printf("\nFile can not open!");
getch();
exit(0);
}
while(!feof(fp)){
c=fgetc(fp);
putchar(c);
}
fclose(fp);
getch();
}
/*写一个字符*/
#include "stdio.h"
#include "string.h"
main(){
FILE *fp;
char c;
if((fp=fopen("d:\\data.txt","w"))==NULL){
printf("\nFile can not open!");
getch();
exit(0);
}
while((c=getchar())!='#'){
fputc(c,fp);
}
fclose(fp);
}
/*读写字符串*/
#include "stdio.h"
#include "string.h"
main(){
FILE *fp;
char c[80]={""},s[80]={""};
/*写字符串*/
if((fp=fopen("d:\\data.txt","w"))==NULL){
printf("\nFile can not open!");
exit(0);
}
gets(c);
fputs(c,fp);
fclose(fp);
/*读字符串*/
if((fp=fopen("d:\\data.txt","r"))==NULL){
printf("\nFile can not open!");
exit(0);
}
while(!feof(fp)){
fgets(s,80,fp);
puts(s);
}
fclose(fp);
getch();
}

这里估计有你需要的:
http://see.xidian.edu.cn/cpp/u/c13/

综合性强一点的:
http://www.jobui.com/mianshiti/it/cyuyan/4811/
看过本文的人还看过