嘿,伙计,我上次发帖有点邋遢。希望这次看起来好多了。如果你决定帮我,谢谢你抽出时间。我真的很需要。不管怎样,这是个问题。我需要对我的代码进行包装,我听说你可以用模来做,但我不确定我做得是否正确,因为我没有得到正确的结果。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main () {
char s[200]; //blank array//
int mess;
printf("Generations have wondered how the Ceasar Code works\n");
printf("Please choose a number to mess up (encode) the current file\n");
scanf("%d", &mess);
mess = mess % 26;
FILE *ptof = fopen("Rock.txt", "r");
char a[200];//fill array with characters from file//
int i=0;
while( (a[i++]=fgetc(ptof)) != EOF && i < 89) { //get character from file//
}
a[i] = '\0'; /* null-terminate the string */
i = 0;
do{
printf("%c",a[i++]);
} while (a[i] != '\0'); /* print until hit \0 */
int j = 0;
for (j = 0; j < 89; j++){
s[j] = a[j] + mess;
}
printf("%s\n", s);
fclose(ptof);
return 0;
}
最佳答案
s[j] = a[j] + mess
也需要模运算
关于c - 用C换行以获取Ceasar的代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24439672/