Hot answers tagged

1

toupper(s[i]-65) If you give that 'a', then 'a' - 65 is 32. toupper(32) will simply be 32, since 32 is not an ascii char. Be careful with your ()


1

You have a logic error in your declaration of ciphertext. Take a look at how it is declared (it's type) and the type of plaintext. ;) This should hopefully make it clear why one seems to work with multiple letters and the other only one. If this helps, feel free to click the check mark. But if not, let me know and I will help further.


1

The problem lies here: if (key_length != 26 || isalpha(argv[1])) The isalpha() function and all of it's cousin issomething() functions take a single char as input. If you try to give it a string (argv(1) is a string, not a char, even if it only has one char), it causes a seg fault. It's that simple. As for debug50, it is a wrapper around gdb. Think of it ...


1

The documentation for isalpha explains that the input should be an unsigned char. https://manual.cs50.io/3/isalpha By passing in a string instead of a single char, the underlying library code is misbehaving. Too bad it's not a compile error. Why debug50 behaves differently, there's probably different library code being executed. Many advanced things happen &...


1

Program doesn't know if all the characters in key are digits until after it has processed all of them. The "Success" message should come after the for loop is finished. And remember this hint from the spec: Recall that we can return nonzero values from main to indicate that our program did not finish successfully. As soon as a non-digit is found, ...


Only top voted, non community-wiki answers of a minimum length are eligible