Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to know what I did wrong in my code, it is not doing what I want it to do

ID: 3601821 • Letter: I

Question

I need to know what I did wrong in my code, it is not doing what I want it to do. Please arrange it so that it matches the specifications without changing the code I used so I can see where I went wrong.

Design and implement a program that encrypts messages using Vigenère’s cipher. Implement your program in a file called vigenere.c in a directory called vigenere. Your program must accept a single command-line argument: a keyword, k, composed entirely of alphabetical characters. If your program is executed without any command-line arguments, with more than one command-line argument, or with one command-line argument that contains any non-alphabetical character, your program should print an error (of your choice) and exit immediately, with main returning 1 (thereby signifying an error). Otherwise, your program must proceed to prompt the user for a string of plaintext, p, (as by a prompt for plaintext:) which it must then encrypt according to Vigenère’s cipher with k, ultimately printing the result (prepended with ciphertext:and ending with a newline) and exiting, with main returning 0. With respect to the characters in k, you must treat A and a as 0, B and b as 1, … , and Z and z as 25. Your program must only apply Vigenère’s cipher to a character in p if that character is a letter. All other characters (numbers, symbols, spaces, punctuation marks, etc.) must be outputted unchanged. Moreover, if your code is about to apply the jthcharacter of k to the ith character of p, but the latter proves to be a non-alphabetical character, you must wait to apply that jthcharacter of k to the next alphabetical character in p; you must not yet advance to the next character in k. Your program must preserve the case of each letter in p.

#include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int letter; int shift;
int main(int argc, string argv[1]) {

if(argc != 2)
printf("Invalid Entry. ");
return 1;
}
string keys = argv[1];
plain_len = strlen(keys);
for (int i = 0, keylength = strlen(argv[i]); i < keylength; i++) {

if ((keys[i] >= '0') && (keys[i] <= '9'))
printf("you were supposed to enter a word with only letters. ");
return 1;
}

}
keys[i] = toupper(keys[i]);
}
{
string plaintext = get_string("plaintext: ");
printf("ciphertext: ");
int reference = 0;
for (int i = 0, r = strlen(plaintext); i < r; i++
}

if (isalpha(plaintext[i]))

}
{
int keys = keys[reference]- 'A'

if ((plaintext>='A') && (plaintext<= 'Z'))
{
plaintext=(plaintext - 'A');
}

if ((plaintext >+ 'a') && (plaintext <= 'z'))
{
plaintext = (plaintext - 'a');
}

reference =(reference + 1);
{
printf("%c", plaintext[i]);
}
printf(" ");
return 1;
}

Explanation / Answer

#include #include #include #include int main(int argc, string argv[]) { // rejecting more or less than 2 command line inputs if (argc > 2 || argc < 2) { printf("usage: ./vigenere k "); return 1; } // rejecting non-alpha int m = strlen(argv[1]); for (int i=0; i