#include "Stdio.h"
#include "Conio.h"
#include
int main()
{
test1();
getch();
return 0;
}
test1(){
char ch;
FILE *fp;
FILE *outfp;
char str[800];
char cc=' ';
long count=0;
char *filename="c://upwing//word2a.txt";
char *filename2="c://upwing//word2b.txt";
if((fp=fopen(filename,"rb"))==NULL){
printf("can't open %s/n",filename);
getch();
exit(1);
}
if((outfp=fopen(filename2,"ab"))==NULL){
printf("can't open %s/n",filename2);
getch();
exit(1);
}
while(ch=getc(fp),ch!=EOF){
putc(ch,outfp);
printf("%X ",ch);
str[count]=ch;
count++;
}
str[count]='/0';
/*puts("/n/n lichen de shu chu:/n/n"); */
/*puts(str); */
if(fclose(fp)!=0){
printf("close file failed 1/n");
}
if(fclose(outfp)!=0){
printf("close file failed 2/n");
}
printf("/nfile %s has %ld characters/n",filename,count);
getch();
}
test2(){
int ch;
FILE *outfp;
char str[800]="1234567890/t1234567890/r/nABCDEFGHIJKLMN/r/n,.//r/n樃晄?堈?恖?/r/nAAAAABBBBBCCCCC";
char *filename2="c://upwing//word2a.txt";
int n;
str[64]=0xFF;
if((outfp=fopen(filename2,"wb"))==NULL){
printf("can't open %s/n",filename2);
getch();
exit(1);
}
for(n=0;n<800;n++){
if(str[n]=='/0'){
break;
}
putc(str[n],outfp);
}
if(fclose(outfp)!=0){
printf("close file failed 2/n");
}
printf("/nfile %s has %ld characters/n",filename2,n);
}