不過,亂try各種類型的測資時,惱人的問題出現了,目前只能讀ASCII file (如: *.c *.bat *.txt ... ) ,對於 執行檔 (如: *.exe) 及 圖檔 (如: *.jpg *.gif ) 都還不能做完整的加解密 , 上網查了一下資料,查到了 fread() 和 fwrite() 這類的function可以做整串流的文字讀取,看來,只好用 fopen("
FILE *infile,*outfile;
char infilename[50]="Lena512.raw"; // input file name
char outfilename[50]="Lena.raw"; // output file name
unsigned char **Y; // pointer for Y component
int i;
//open input file
if((infile=fopen(infilename,"rb"))==NULL){
printf("Input file %s can't be opened!\n",infilename);
return 0;
}
//dynamically allocate 2D memory for Y component
Y = (unsigned char **)malloc(height * sizeof(unsigned char *));
for(i = 0; i < i =" 0;">fread(Y[i],width,sizeof(unsigned char),infile);
fclose(infile);
// write Y component
outfile=fopen(outfilename,"wb");
沒有留言:
張貼留言