3
votes
Accepted
CS50 PSET2 Check 50 Hello world trouble. Caesar cipher segmentation fault and encipher the plaintext
isupper() does not work on strings, it only works on chars, that's why you get the seg fault.
"I did not find anything that helped to iterate over the chars of p. Can you give me a hint on how to do ...
2
votes
Accepted
Errors in Caesar pset2 and Wrong Output
You're getting a seg fault because the code tries to work with argv[1] before checking whether it exists. "Ready, Fire, Aim!"
The very first thing that must be done is to check the value of ...
1
vote
Accepted
I'm stuck at PSet 2 Caesar Cipher: The alphabets don't follow my modulo 26. It goes beyond it, printing non-alphabetic characters
The problem lies here:
int asciiValue = plaintext[i]+key%26;
Simply put, it won't work at all. plaintext[i] contains an ASCII value for a letter. That's a number somewhere between 65 and 122 ...
1
vote
Caesar pset2 How to Reprompt user for Command Line Argument?
You can't reprompt a user for command line arguments. You will have to exit the program after printing the usage.
1
vote
Caesar pset2 How to Reprompt user for Command Line Argument?
Perhaps a review of the class material on command line arguments is in order?
https://cs50.harvard.edu/x/2020/notes/2/#command-line-arguments
1
vote
Caesar problem: Validating keys
They are right, your program is only checking the first character of argv[1].
Try to think - your for loop checks the first character; if its not a digit, it throws an error and ends the program. Or ...
1
vote
i can not submit my assesments how do i go about it
You have to submit from the directory where the files to submit are, like ~/workspace/pset2/caesar/ or wherever you put the caesar.c file. You can use cd command ("change directory") to make this your ...
1
vote
Accepted
caesar.c questions
Your problem occurs here:
for(int i = 0, n = strlen(plaintext); i <= n; i++)
If we look at the first test case, plaintext is a, which has length of 1. Based on your for loop, you will allow keep ...
1
vote
\ expected output, but not "plain text: "
There is a subtle but significant difference between what the spec requires and what your program produces.
What the spec requires:
Your program must output plaintext: (without a newline) and ...
1
vote
Accepted
Pset2 Caesar Cipher - compiles but doesn't look right
You have an extra (misplaced) {something} in some printf statement. What would cause every letter to print on a "new line"?
Some unsolicited advice.
Recall from the spec:
So that we can automate ...
1
vote
Accepted
Pset-2 Caesar Cipher : Output not matching
You need to print a linefeed char '\n' after the chipertext.
So it should be printf("%s\n", et); instead of printf("%s", et);
If this solves your problem, please click the check mark to accept the ...
1
vote
Accepted
pset2 caesar please help
cipher = (chr+key) % 26
So, if you enter, say d and a key of 5, then:
cipher = ('d' + 5) % 26
cipher = (100 + 5) % 26
cipher = 1
1 is a non printable char.
The formula for caesar given in the pset ...
1
vote
Caesar Cipher Formula Question
Ok, First have a look at the if condition that you are implementing for checking if the character is an alphabet. Let us assume the letter at a certain time that is being ciphered is 'M' and the key ...
1
vote
Not sure why I keep getting the \expected output not prompt for input
I'm not sure why you are getting those specific errors. Perhaps you are running an old version of your code? I have noticed recently that when a file in the IDE is saved, sometimes the file doesn't ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
caesar-cipher × 20pset2 × 14
caesar × 14
pset2-caesar × 6
cs50x × 3
check50 × 3
cipher-pset2 × 2
c × 1
segmentation-fault × 1
fails-check50-but-works × 1
cs50x2017 × 1
spoiler × 1
caeser × 1
problemset2 × 1
bool × 1