Hi,
I am writing a encryption problem that uses ceasar cyphering system. User is meant to enter in the command line the programme, string and a key that will determing how far the characters should be moved in the ASCII chart. My program is returning a segmetation error. Please help to identify the error
Code:# include <stdio.h>
# include <cs50.h>
# include <stdlib.h>
# include <string.h>
# include <ctype.h>
int main(int argc, string argv[])
{
//command line to have three entries or else quit
if (argc !=3)
return 1;
{
string s = argv[1];
//int length = strlen(s);
//iterate through the string
for (int i = 0; i < strlen(s); i++)
{
//char kar = s[i];
int ch = 's[i]';
int key = atoi(argv[2]);
if ( isalpha("ch"))
{
bool upper = true;
do
{
int value_u = (ch + key);
int result_u;
int Z = 'Z';
{
if (value_u > Z)
{
result_u = value_u % 26;
printf("%c",result_u);
}
else
printf("%c",result_u);
}
}
while (upper == false);
{
int value_l = (ch + key);
int result_l;
int z = 'z';
{
if (value_l > z)
{
result_l = value_l % 26;
printf("%c",result_l);
}
else
printf("%c",result_l);
}
}
}
else
printf("%c",ch);
}
printf("\n");
}
return 0;
}