我已經從here獲取了一個簡單的凱撒密碼的代碼,我修改了它,以便用戶定義密碼密鑰。但每次我嘗試運行它時,程序都會崩潰。凱撒密碼簡單程序
#include <stdio.h>
int main()
{
char array[100], cipher[100];
int c=0, x=0, y=0;
int z;
printf("This Program will encrypt according to your needs\n");
printf("Enter the cipher key\n");
scanf("%d",&z);
printf("Enter the sentence");
while((c=getchar()) != '\n')
{
array[x++]=(char)c;
cipher[y++]=(char)(c+z);
}
array[x]=0;
cipher[y]=0;
printf("%s\n",cipher);
return 0;
}
如果它崩潰使用調試器,曾經有一次我使用日誌語句進行調試......通過花費一個小時學習如何使用調試器可以節省的時間......我很笨,你d不一定非要。 –
你的代碼有什麼問題?我試過了,它不會崩潰 – WileTheCoyot