嘿,伙计,我上次发帖有点草率。希望这次看起来会好很多。如果您决定帮助我,谢谢您的宝贵时间。我真的需要它。无论如何,这是问题。我需要为我的代码环绕,我听说你可以用模数来做,但我不确定我做的是否正确,因为我没有得到正确的结果。
#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
也需要模运算
我是一名优秀的程序员,十分优秀!