首先让我说这个标准是必需的,也是我目前必须使用的。
无论如何,我遇到了一个错误,并尝试将我的 FILE * 块全部移动到内部/外部,在可执行文件之前等。
#include <stdio.h>
#include <stdlib.h>
/* Initialize vars */
char c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12;
int main()
{
/* Open encrypted.txt for reading */
FILE *enc;
enc = fopen("encrypted.txt", "r");
/* Retrieve individual characters, displace by 4 letters (decryption method) */
c1 = (getc(enc))-4;
c2 = (getc(enc))-4;
c3 = (getc(enc))-4;
c4 = (getc(enc))-4;
c5 = (getc(enc))-4;
c6 = (getc(enc))-4;
c7 = (getc(enc))-4;
c8 = (getc(enc))-4;
c9 = (getc(enc))-4;
c10 = (getc(enc))-4;
c11 = (getc(enc))-4;
c12 = (getc(enc))-4;
/* Display resulting decrypted message */
printf("%c%c%c%c%c%c%c%c%c%c%c%c", (char)c1, (char)c2, (char)c3, (char)c4, (char)c5, (char)c6, (char)c7, (char)c8, (char)c9, (char)c10, (char)c11, (char)c12);
/* Write decrypted message to new file named "decrypted" */
FILE *dec;
dec = fopen("decrypted", "w");
fprintf(dec,"%c%c%c%c%c%c%c%c%c%c%c%c", (char)c1, (char)c2, (char)c3, (char)c4, (char)c5, (char)c6, (char)c7, (char)c8, (char)c9, (char)c10, (char)c11, (char)c12);
/* Close files */
fclose(enc);
fclose(dec);
}
任何有关如何摆脱此错误的提示表示赞赏!提前致谢