i'm stuck on vigenere for very longtime and i don't know whats wrong with my code, can you please check it out and tell me what's wrong with it?
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc,string argv[])
{
int g = strlen(argv[1]);
if(argc != 2)
{
printf("type the index element\n");
return 1;
}
for(int i = 0; i < g; i++)
{
if(!isalpha(argv[1][i]))
{
printf("type letters from a to z only please :|\n");
return 1;
}
}
printf("type your text here please: ");
string x = GetString();
for(int i =0, n = strlen(x); i<n;i++)
{
int key1 = (argv[1][i]-65)%g;
int key2 = (argv[1][i]-97)%g;
char result;
if (isalpha(x[i]))
{
if (isupper(x[i]))
{
int num = ((x[i]-65) + key1)%26;
result = num + 65;
}
if (islower(x[i]))
{
int num = ((x[i]-97) + key2)%26;
result = num + 97;
}
printf("%c",result);
}
else
{
printf("%c",x[i]);
}
}
printf("\n");
}