回复 13楼 pangding
void transe_abc()
/*把abc.txt文件转换成abc.enc
把每个字符8个字节删减为只保留后面7个字节*/
{
FILE *fip =fopen("abc.txt", "rb");
FILE *fop =fopen("temp", "wb");
int
e;
char f = 0;
int
g = 8;
int c;
char b[2048];
char d[2048];
int k;
int i = 7;
int j = 0;
int l = 0;
fread(&c, 1, sizeof(char), fip);
while(!ferror(fip) && !feof(fip)){
k = 7;
while(k-- >0){
if(c >> k & 0x00000001){
b[j++] = '1';
d[l++] = '1';
}
else{
b[j++] = '0';
d[l++] = '0';
}
b[j++] = ' ';
if(--i == 0){
b[j++] = 0;
j = 0;
i = 7;
}
}
fread(&c, 1 ,sizeof(char), fip);
}
if(i){
while(i--){
printf("
");
}
b[j] = 0;
}
printf("%s",d);
for(e=0; e<strlen(d); e++){
if (d[e] == '0'){
f = f<<1;
g--;
}
else if (d[e] == '1'){
f = f<<1;
f += 1;
g--;
}
if (g == 0){
fwrite(&f, 1, sizeof(f), fop);
f = 0;
g = 8;
}
}
if (g != 8){
while (g--){
f = f << 1;
}
fwrite(&f, 1, sizeof(f), fop);
}
fclose(fip);
fclose(fop);
system("del abc.txt");
system("move temp abc.enc");
}
=_=好了.....我没学过别的语言.....终于搞掂了...txt转换enc
取后七个字符..加密...
现在问题又来了=_=解密.....enc变回txt
~~我知道是在前面加个0.但不知道怎么表达。。。