Problem with segmentation. I can compile the program, but can't run. Questions about segmentation fault were asked many times, but I still don't know. I think problem with command-line argument — I simply don't know how to use it. Eventually all I get — runtime error: load of null pointer of type 'char' (k1 = *argv[1];) Segmentation fault
#include <stdio.h>//printf
#include <stdlib.h>//atoi
#include <cs50.h> //get_string, get_int
#include <string.h>//strlen
#include <math.h>//fmod, fmodf, fmodl
int main(int argc,char *argv[])
{
if (argc != 1)
{
printf("error: less or more than one command-line arguments\n");
return 1;
}
//Получение открытого текста
int q,i,j,b,k;
char k1;
double a;
k1 = *argv[1];
k = atof(&k1);
string f=get_string("plaintext: ");
char Alpha[26], lAlpha[26];
//Получение длины открытого текста
q=strlen(f);
for (i=0;i<25;i++)
Alpha[i]=i+65;
for (i = 0;i<25;i++)
lAlpha[i]=i+95;
//Данный цикл проходит все значения (буквы) открытого текста
for (i=0;i<q;i++)
//Данный цикл проходит все значения (буквы) алфавита
for(j=0;j<26;j++)
{
//Сравнение букв открытого текста с буквами алфавита
if (f[i]==Alpha[j])
{
//Операция по нахождению остатка от деления номера буквы
a=fmod(j+k,26);
b=a;
f[i]=Alpha[b];
break;
}
//Сравнение букв открытого текста с буквами алфавита
if (f[i]==lAlpha[j])
{
//Операция по нахождению остатка от деления номера буквы
a=fmod(j+k,26);
b=a;
f[i]=lAlpha[b];
break;
}
}
printf("ciphertext: %s\n",f);
}