我的思路是新建一个二进制文件,然后从文本文件读出数据,写入二进制文件,可是我打开这个二进制文件后,发现还是和原来文本文件相同。
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#define MAX_SIZE 1000
#define off 8L;void fatal(char * s)
{
printf("error %s\n",s);
exit(-1);
}
void  filechange(char *infile, char * outfile)
{
FILE * infd = NULL,* outfd = NULL;
char ch;

if((infd=fopen(infile,"r"))==0)
fatal("open infile in change");



if((outfd=fopen(outfile,"wb+"))==0)
        fatal("create outfile in change");        while(!feof(infd))
{
ch=fgetc(infd);
if (ch == ' ')
continue;
fputc(ch,outfd);
}
}
int main(int argc, char * argv[])
{
char * s = "encryto.txt";
char * p = "datatemp.txt";
        
if(fopen(s,"r") ==0 )
fatal("open encryto.txt failed");
filechange(s,p);
return 0;
}