Hey all I asked a question related to this code earlier and got a lot of helpful answers (I'm very green at coding). While I overcame my initial problem and corrected a few more mistakes I've run into another error that I can't seem to fix. I keep getting the Segmentation fault but I want it to prompt the user to give a second argument. Along with that when I do give the number, the code doesn't seem to actually encrypt the text Any suggestions or blaring issues I missed?
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, string argv[])
{
int num;
int k = atoi(argv[1]);
string output;
if(argc != 2)
{
printf("K not included in command");
return 1;
}
string s = get_string("Insert Lowercase Message:");
for (int i = 0, n = strlen(s); i < n; i++)
{
char c = s[i];
if (c >= 'A' && c <= 'Z')
{
num = 'A';
if (c >= 'a' && c <= 'z')
num = 'a';
printf("%c", (c - num + k) % 26 + num);
}
else
printf("%c", c);
}
}