c - Vigenere cypher program error for cs50 -
i'm writing vigenere cypher program in c cs50 , have working perfectly. error when encryption wraps around output ? symbol in white circle.
below code;
#include <cs50.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]) { char a; char letter; char cryptletter; char passletter; string message; int messcount = 0; if(argc != 2) { printf("command line must contain 1 passphrase\n"); return 1; } for(int i=0; < strlen(argv[1]); i++) { = argv[1][i]; if(isalpha(a) == 0) { printf("encryption keyphrase must contain alphabetic characters\n"); return 1; } } message = getstring(); (int j = 0; j < strlen(message); j++) { letter = message[j]; if(passletter < 91 && passletter > 64) { passletter = passletter + 32; } if(isupper(letter) != 0) //if uppercase 65-90 { passletter = argv[1][messcount]; cryptletter = passletter + letter - 97; if(cryptletter > 90) { cryptletter = cryptletter - 25; } printf("%c", cryptletter); messcount++; } if(islower(letter) != 0) //if lowercase 97-122 { passletter = argv[1][messcount]; cryptletter = passletter + letter - 97; if(cryptletter > 122) { cryptletter = cryptletter - 25; } printf("%c", cryptletter); messcount++; } if(messcount > strlen(argv[1])-1) { messcount = 0; } if (isalpha(letter) == 0) { printf("%c", letter); } } printf("\n"); }
any appreciated, having similar problem caesar cypher. thanks
here:
if(passletter < 91 && passletter > 64)
passletter uninitialized
Comments
Post a Comment