私のコードでは、意味がわかりませんが、エラー メッセージのセグメンテーション違反が繰り返し表示されます。Caesar 暗号を作成しようとしていますが、コードでエラー メッセージが表示され続けます。問題が何であるかはわかりません。助けていただければ幸いです。
#include <stdio.h>
#include<cs50.h>
#include<string.h>
#include<ctype.h>
void encrypt(int k,string text);
int main(int argc,string arcv[])
{
if(argc != 2)
{
printf ("Please return a vaild command line argument");
return 1;
}
else
{
printf("Enter your text here:");
string s = GetString();
int x;
x = (int) (arcv[1] - '0');
encrypt(x,s);
}
}
void encrypt(int k,string text)
{
if(k > 26)
{
k = k % 26;
}
for(int i = 0;i < strlen(text); i++)
{
if(isalpha(text))
{
printf("%c",text[i] + k);
}
else
{
printf("%c",text[i]);
}
}
}