0
我的任務是創建一個vigenere密碼,但我的程序不打印任何東西。事情是,我不確定問題在哪裏;是沒有閱讀的文件,是我的邏輯不正確,等等?任何幫助,我在哪裏搞錯讚賞。C Vigenere Cipher Not Printing
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void encrypt(char *theString, int shift)
{
if (isalpha(*theString) && isupper(*theString))
{
*theString += shift;
if (*theString >= 'Z')
{
*theString = *theString - 26;
}
}
theString++;
}
int main(void)
{
FILE *inputFile;
char KEY[256];
char theString[80];
int shift;
int i;
inputFile = fopen("code.txt", "r");
if (inputFile == NULL)
{
printf("Failed to open\n");
return(0);
}
fgets(theString, sizeof(theString), stdin);
printf("Enter the Key: ");
fgets(KEY, sizeof(KEY), stdin);
for (i = 0; i < 256; i++)
{
shift = KEY[i] - 65;
encrypt(theString,shift);
puts(theString);
}
return(0);
}