Skip to main content

Questions tagged [caesar]

Caesar Cipher, one of the assignments in Problem Set 2.

Filter by
Sorted by
Tagged with
9 votes
4 answers
10k views

What's the point of the modulo operation in the Caesar cipher formula?

According to the problem set specification, the formula for encrypting a message using the Caesar cipher is: ci = (pi + k) % 26 I don't get why you need to do modulo 26. What does it even do here?
Xihai Luo's user avatar
  • 305
5 votes
4 answers
8k views

How to handle the lack of argv[1] in caesar?

I think my program handles lack of argv[1] correctly, yet it fails check50's test. here my code: if ( argc != 2 ) printf ("usage : ./caesar + key \n"); return 1;
user avatar
4 votes
1 answer
2k views

pset6 - caesar - check50 error: "expected exit code 1, not 0"

I scored the web after an answer, found it, but still doesn't work. My caesar.py works fine, check50 shows me all happy faces except the last: :( handles lack of argv[1] expected exit code 1, not ...
Daniel da Rocha's user avatar
4 votes
2 answers
2k views

How to handle "lack of argv[1]"

I have my code set up so that if argc doesn't equal 2 the main function will return 1. Per the specs I thought. But I keep getting the error that I didn't "handle lack of argv[1]". if (argc != 2) ...
Brian Hodges's user avatar
3 votes
1 answer
1k views

Why doesn't caesar pass check50 even though the output is correct?

I have solved caesar, but check50 is not recognizing my results as correct. :) caesar.c exists :) caesar.c compiles :( encrypts "a" as "b" using 1 as key \ expected output, but not "b" :( encrypts ...
crack64's user avatar
  • 35
2 votes
2 answers
14k views

"Expected Expression" error on else function in caesar.c

I am working on pset2, caesar.c, and I am currently getting the error message below: caesar2.c:32:9: error: expected expression else if (islower(plaintext[i])); ^ caesar2.c:38:9: error: expected ...
Roxanne's user avatar
  • 33
2 votes
1 answer
1k views

Ascii Becomes Negative?

So I'm I just started pest 2 and it was pretty smooth until I found a horrible bug in my code. Essentially the code works fine when the entire plain text string is in upper case, but it gives me a ...
vanugrah's user avatar
2 votes
1 answer
523 views

Caesar code only works correctly when I add a random printf statement

My Caesar code seems to be working correctly in this form: #include <cs50.h> #include <stdio.h> #include <string.h> // validates that the key is only numbers int validate_key(...
Vasilis D's user avatar
2 votes
1 answer
8k views

Checking to see if the contents of a string is an integer

Currently I am working on Caesar and validating the user inputs. The argument count section works fine. However, I can't find a way to compare the value in the vector argument string (argv[1]) to see ...
Andrew Alton's user avatar
2 votes
1 answer
477 views

Pset2 - caesar - segmentation fault

my program compiles but when I input the plain text and run it, I get a segmentation fault. What am I doing wrong? #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
Jana B.W.'s user avatar
1 vote
3 answers
7k views

Segmentation fault (core dumped) in caesar

After starting caesar with an additional argument and providing the sentence that needs to be encrypted, the Terminal shows this response: jharvard@appliance (~/Dropbox/pset2): ./caesar 1 abcdef ...
Kotlet's user avatar
  • 101
1 vote
1 answer
318 views

This should be right (Caesar)

After spending pretty much a whole day on this, I have gotten it to work fine, it does all that was demanded but when submitted, I am still getting 1/5 on correctness. :( someone tell me if I left ...
Stephen Mbonu Ugochukwu's user avatar
1 vote
1 answer
1k views

I have "handles non-numeric key timed out while waiting for program to exit" problem inPset 2 and I can't solve it

here is my code: #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #include <stdlib.h> int main(int argc, string argv[]...
santiago correa's user avatar
1 vote
1 answer
229 views

What is the logical difference between if (isupper(text[i]) == true) and if (isupper(text[i]))?

In my original code I had this: if (isupper(text[i]) == true) { int j = (int) text[i] % 65; int k = (j + key) % 26; char l = (char) k + 65; ...
Jacopo Stifani's user avatar
1 vote
1 answer
462 views

Pset 2 Caesar doesnt output spaces correctly and more :(

Really having a hard time doing this caesar problem my cipher text is not taking spaces to account and when I type in ./caesar by itself it gives me a message like this: caesar.c:10:18: runtime ...
Roundabout's user avatar
1 vote
2 answers
131 views

Line length too long

I just finished the Caesar program and it works, but when I run style50 it complains that this line is too long: if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && ...
Jonobugs's user avatar
1 vote
2 answers
112 views

I truly confused on why ceaser won't work,

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
Carl Singleton's user avatar
1 vote
1 answer
63 views

Pset2 Caesar - Segmentation fault error

First off, I will show my code: int main(int argc, string argv[]) { if (argc != 2) { printf("Wrong command line arguments\n"); return 1; } else { ...
Jaime's user avatar
  • 15
1 vote
1 answer
195 views

Check50 for caesar, pset2 returns an error "Not valid ASCII text" twice, even though it encrypts correctly for the same text used in check50

Okay, the code is given below (forgive me if there are too many comments!!). Please help!! Code: //the objective of the program is to create a simple encryption of the text inputted by the user with ...
AwesomeRAG7's user avatar
1 vote
1 answer
56 views

Caesar code error

My code was running fine except that it does not bring error message when you execute ./caesar with a letter eg ./caesar hey , but it brings the error message when you use more than one argument eg ....
Stephen Mbonu Ugochukwu's user avatar
1 vote
1 answer
56 views

Python Caesar not working for mix case etc

I've pretty much gotten my program to work 90% successfully! But, it does not produce the correct outcome for mix case or spaces/symbols. I've tried a number of different methods to no avail. At the ...
Beyn18's user avatar
  • 21
1 vote
1 answer
51 views

Need some more help pset2 Ceasar

I'm still trying to figure out why my code isn't working, if anyone can offer any insight, it would be very appreciated! #include <cs50.h> #include <ctype.h> #include <string.h> #...
Xathia's user avatar
  • 13
1 vote
1 answer
63 views

Caesar compiles, but gives the wrong cyphertext

Hi guys, I'm struggling with my caesar program. I believe I've touched on every specs requirements, but the expected result isn't here. For instance, using a key of 1, "ABC" becomes "C". Please see my ...
Phil's user avatar
  • 13
1 vote
2 answers
212 views

Pset2 Caesar is not printing non-alphabetic characters

My Caesar for problem set 2 seems to encrypt my plaintext correctly. My problem is just that it won't print any non-alphabetic characters. For instance, when my plaintext is "hello, world" and the ...
Tenacity's user avatar
  • 157
1 vote
2 answers
89 views

Pset2 Caesar struggle but i gotta do it im from Rome

Ave thanks in advance for your help total newbie trying to make pset2 caesar. here is the error caesar.c:14:1: error: expected identifier or '(' {{ ^ 1 error generated. here is the code #include ...
idbeentaken's user avatar
1 vote
2 answers
379 views

Pset2 - Caesar (less comfortable) wraparound problems

if (isalpha(plain[i])) if (isupper(plain[i])) { printf("%c", ((plain[i]-65) + k) % 26); } if (islower(plain[i])) { printf("%c", ((plain[...
MK3107's user avatar
  • 33
1 vote
2 answers
324 views

pset2, Caesar. Can't pass testing [duplicate]

I have a problem with check my code CS50, my code is below: #include <cs50.h> #include <stdio.h> #include <string.h> //desribe of values //int i - number of arguments //int n - ...
Alexander Lyapunov's user avatar
1 vote
1 answer
188 views

Pset2 Caesar: extra letter printed at the end of ciphertext

I have test many cases and most of them are fine except the following one: ~/workspace/pset2/caesar/ $ ./caesar 2 plaintext: I love tea ciphertext: K nqxg vgcB Where does the extra letter "B" come ...
Han Tang's user avatar
  • 113
1 vote
1 answer
233 views

pset2 caesar, argv[1]

Ok I'm consistently encountering a peculiar issue that I can't get my head around. this loop should return an error if there is a character other than a digit. When I give a character other than a ...
Callum Gander's user avatar
1 vote
1 answer
847 views

Check50 fails but my code works! [duplicate]

I have done my pset2 but my code fails check50 even though the code is correct and encrypts the text correctly. Here is the check50 output: :) caesar.c exists :) caesar.c compiles :( encrypts "a" as "...
Code's user avatar
  • 27
1 vote
1 answer
47 views

help with Caesar problem from Pset2

EDIT: Here is the new "only_digits" function that I'm struggling with: bool only_digits(string s) { for (int i = 0, j = strlen(s); i < j; i++) { if isdigit(s[i]) { ...
AmyG's user avatar
  • 41
1 vote
1 answer
47 views

Problem Set 2, Ceasar, Testing Check50

I tried the Caesar Problem. Everything is going well, except when I want to test it. It shows that my output and the test output are the same, but my code couldn't pass the test. Even though I checked ...
Subhan SA's user avatar
1 vote
2 answers
3k views

error: unused parameter 'argv'

I am writing this simple code for checking if the user has entered the key or not. If not I want to return 1 and show an error msg. Below is the snapshot of my code which I am using. I am getting the ...
Mohit Sharma's user avatar
1 vote
1 answer
395 views

pset2 Caesar - How to properly implement modulus operator

I understand the necessity of using the modulus operator to compensate for plaintext characters that would surpass Z or z respectively, but I cannot seem to wrap my head around its particular syntax. ...
AvidUrner's user avatar
1 vote
1 answer
156 views

My code is done and working well but I still get red :( faces

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main (int argc, string argv[]) { //...
Cristian's user avatar
  • 117
1 vote
1 answer
45 views

My program doesn't work with or without command lines

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main (int argc, string argv[]) { //...
Cristian's user avatar
  • 117
1 vote
1 answer
119 views

What to do with the ASCII key & math?

I'm having a hard time understanding what to do with the ASCII keys & math formula. I understand that you move your plaintext over by the K amount, however, I'm not sure how to write this in code. ...
Pixeluh's user avatar
  • 25
1 vote
1 answer
513 views

Segmentation fault pset2 caesar

I have been working through the caesar code and all is well until I start playing about with the isupper function. This is where the problem is as I've been compiling and running the rest of the ...
Ailsa's user avatar
  • 13
1 vote
1 answer
374 views

Pset2 caesar unused variable

Hello and thanks for reading. I have created a few functions and at the moment I have no idea if my code works, so I just want to test to see if my code works but I am getting a weird error which I'...
GettingTheHang-of-it's user avatar
1 vote
1 answer
138 views

Why does caesar return this?

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) { if(argc != 2) { printf(...
mmoore's user avatar
  • 57
1 vote
1 answer
131 views

pset2 caesar why not do it this way?

i have watched Zamyla's walkthrough several times and i wonder what if i create an array of the alphabet characters and do the cipher from that. that seems more efficient to me than doing a second ...
rebecca a's user avatar
1 vote
2 answers
93 views

My caesar.c only works for values of k up to 5

I do not know why but when I run my program with k = 6 and I type z I get the weird character � Here is my code: s[i] = s[i] + k; if (s[i] > 122) s[i] = (s[i] % 26 + 78); example with 5 as k ...
Diego Hernandez's user avatar
1 vote
1 answer
644 views

Pset2 (ceasar) - check50 doesn't work

I have a big problem with pset2. I got 0.5 although both programs (vigenere and ceasar) work fine when I test them on my own, without check50. I got 100% for vigenere, and 0% for ceasar. Do you know ...
mimik00's user avatar
  • 13
1 vote
1 answer
51 views

PSET 2 Caesar : help part 3 : ciphertext rotating correctly but not printing out

*Edited to include the latest changes in the code. Can someone help me spot the problem with my code? Below are the results from check50 and the code itself. TIA!! Here is the prior question: PSET 2 ...
AmyG's user avatar
  • 41
1 vote
1 answer
54 views

PSET 2 Caesar : help debugging caesar : continued #2

I'm looking for some (more) help trying to figure out caesar. I finally got it to compile but it's not working properly. When I run check50, it looks like there are two main issues - one, it's not ...
AmyG's user avatar
  • 41
1 vote
0 answers
434 views

How do you call a boolean function in main?

In problem set two it asks to use a separate function outside of main to determine if the string argv[1] has digits. I believe I've done this correctly in that function, but I'm struggling to call it ...
Alexander Siewert's user avatar
1 vote
1 answer
244 views

Unable to confirm user input is a number using isdigit in c

My code is attempting to; take user input from the command line; check if the input is a whole number; confirm positively if so; confirm negatively if not; however all numbers return a negative ...
Shaun's user avatar
  • 13
1 vote
1 answer
232 views

Why is it a segmentation fault when argc is 1 only i.e if I input "./caesar" only? It contains some other errors as well given in screenshot

My program perfectly encrypts texts if user gives a key or enters a wrong key such as an alphabet. But if argc is 1, then I incur a segmentation fault. I also incur a few other problems when I apply ...
Raiyan Rabbani's user avatar
1 vote
1 answer
71 views

Error in Caesar , can't fix . Need help

#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(int argc, string argv[]) { if (argc == 2) ...
Mahip's user avatar
  • 11
1 vote
1 answer
87 views

right track pset 2?

To whoever is reading this, I have been working on the caesar cipher and i wrote a few stuff on gedit. I am not sure if this is correct or waaaay of. Please help me Thanks and have a great day :) #...
Ani's user avatar
  • 61

1
2 3 4 5
9