Questions tagged [pset2]

The problem set for Week 2 continues with the C programming language used in problem set 1.

Filter by
Sorted by
Tagged with
0 votes
3 answers
25k views

How to Wrap Around Array Indexes?

I have the Vigenere encryption portion working properly, but can't seem to figure out how to wrap around argv[1] indexes. My first for loop declared two ints, i and j, and incremented each int with ...
nateyu's user avatar
  • 1
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
2 votes
1 answer
487 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
1 vote
1 answer
287 views

Initials program results in "Segmentation fault(core dump)?

I'm doing the first problem in pset2 and having issues with segmentation faults. Whenever I run the program and enter a string, the error occurs. Based on the lecture I'm assuming it has something to ...
Alec Rodgers's user avatar
1 vote
2 answers
54 views

Pset-2 Caesar Cipher : Output not matching

#include <stdio.h> #include <cs50.h> #include <string.h> #include <stdlib.h> #include <ctype.h> int main (int argc, string argv[]) { if (argc != 2) { printf("...
Manya Agarwal's user avatar
0 votes
1 answer
111 views

I can't check my exercise (pset2, caesar)

I have a problem with ceasar. text of my code: #include <cs50.h> #include <stdio.h> #include <string.h> //desribe of values //int i - number of arguments //int n - lenght of ...
Alexander Lyapunov's user avatar
0 votes
1 answer
123 views

Pset2 initials problem with printing extra initials

I'm struggling with printing the initials after the first name, I'm following the less comfortable specs, my pseudocode; //prompt user for name and store as string //convert strlen to an integer //...
Thomas Forrest's user avatar
0 votes
1 answer
869 views

pset2 - caesar - check 50 passes except for one weird error

Here's what I'm getting back - thoughts on how to fix this? jharvard@appliance (~/Dropbox/pset2): check50 2014/x/pset2/caesar caesar.c :) caesar.c exists :) caesar.c compiles :) encrypts "a" as "b" ...
jsa724's user avatar
  • 3
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
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
1 answer
308 views

Expression result unused in Vigenere

I am getting this error: expression result unused and I don't know what that means. I use the code it's pointing to (green underline), just like I do in my Caesar cipher which works: The other posts ...
Azurespot's user avatar
  • 203
1 vote
1 answer
176 views

Can't get the 'z' using % 26 on my Vigenère Cypher

I've been trying for a while to get this right but I guess I can't do the math. I'm using this line to encrypt each character for the Vigenères Cypher: int letter = ((p(i) - 96) + (k[j] - 97) % 26 + ...
Ivan's user avatar
  • 13
1 vote
2 answers
263 views

pset2 - readability - grades slightly off

I have a problem that I have not been able to diagnose on my own or by perusing this stack overflow. The the tests are here. All of the index values are correct except for the grade seven sentence ...
m.ravetch'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
459 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
1 answer
180 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
970 views

Pset2 - Crack: How to iterate through all combinations of alphabet

Probably a silly question, but please bear with me as I'm pretty new to this. I'm stuck with Crack in Pset2. Can't wrap my head around how to go about iterating through all combinations of alphabet. ...
Branos's user avatar
  • 11
0 votes
1 answer
75 views

pset2 caesar, key is always zero [duplicate]

#include<stdio.h> #include<cs50.h> #include<string.h> #include<stdlib.h> #include<ctype.h> int main(int argc, string argv[]) { int i= atoi(argv[1]); string p = ...
Sangwan7447's user avatar
0 votes
1 answer
95 views

problem with "z" for vigenere

here is my code: #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(int argc, string argv[]) { if (argc != 2) ...
Alvin Leong's user avatar
0 votes
1 answer
90 views

Pset3 help : vigenere error

I have this error. Please Help ~/workspace/pset2/ $ make vigenere clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow ...
WhipStreak23's user avatar
0 votes
1 answer
192 views

Gradebook issue

So far i have submitted PSET0, PSET1, PSET2, PSET3. I have submitted both standard and hacker editions. I have following grades so far: PSET0....................1.0 PSET1 PSET2...............
Laxman Rawat's user avatar
0 votes
1 answer
319 views

Vigenere fails check50 test encrypts "BaRFoo" as "CaQGon" using "BaZ" error

Vigenere fails check50 test encrypts "BaRFoo" as "CaQGon" using "BaZ" error, my program output is "caQGoh". I don't know what's the problem but i guess that this problem apears when there are ...
Avan logic's user avatar
0 votes
1 answer
39 views

why I have additonal output for caesar program?

I have below code written and majority of code is working, but when do check CS50, I have additional output if crypt "a" using k=1 #include <cs50.h> #include <stdio.h> #include &...
Eat个apple's user avatar
0 votes
2 answers
191 views

Caesar output extra characters in capitals only

My caesar code works well for lower case but adds extra characters for upper case even though I used the same strategy in coding. :( encrypts "BARFOO" as "EDUIRR" using 3 as a key \ expected output, ...
infojunkie's user avatar
0 votes
1 answer
700 views

Inaccuracy in Readability Test Case

I have been testing my code with check 50 and one of the test cases - is calculated as Grade 9 in my program vs Grade 8. https://submit.cs50.io/check50/1bffffe43d39fcfdc8d7a8885bbf59b47b718918 Test ...
rajarshc's user avatar
0 votes
1 answer
404 views

CS50 Readability - Inconsistency in results

This is my 1st post here. I am taking CS50 and I am stuck trying to figure out why the results for this weeks problem set are delivering inconsistent results. My code is below. It passes most of the ...
Closeupgamer's user avatar
0 votes
3 answers
1k views

How to Ignore Ciphering Non-Alphabetical Characters in Vigenere?

I get these 3 errors when checking viginere with check50 :( encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword \ expected output, but not "xomqd, szz gflkp!\n" :( encrypts ...
user avatar
0 votes
1 answer
170 views

cs50 pset2/vigenere - code doesn't work if text and key differ upper/lower case

I Don't know how to make code work if key is lowercase and text uppercase and vice-versa. Before I considered case sensitivity my code would work except for a few letters. Now it wont output full ...
Jana B.W.'s user avatar
0 votes
0 answers
65 views

Please help, i keep hitting segmentation faults on this code

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <stdlib.h> #include <string.h> int main(int argc, string argv[]) { if ( argc > 2 || argc < 2 ) ...
Brenda's user avatar
  • 23
0 votes
1 answer
1k views

Why does strlen of argv become zero in my code?

I was doing the Vigenere cipher and wanted to translate all the characters into ints 0-25 to be used as the key. I got floating point exception core dumped error. I did an inspection of my code and ...
Lucas's user avatar
  • 171
0 votes
1 answer
95 views

pset2 caeser boolean returns

when running the code below with a command line ./caesartest 2, I get the false return 1, not the true, what is wrong? (I began having the trouble after including isdigit)... #include <cs50.h> #...
Samir-B's user avatar
  • 11
0 votes
1 answer
334 views

Pset2, Vigenere error "\ expected output, not a prompt for input" when I run check50

I get this error when I run check50 ~/workspace/pset2/ $ check50 2016.vigenere vigenere.c :) vigenere.c exists :) vigenere.c compiles :( encrypts "a" as "a" using "a" as keyword \ expected output, ...
mgcoast's user avatar
0 votes
1 answer
311 views

extra characters in Vigenere pset2 2016

I am working on the Vigenere pset and seem to be getting the correct encryption but the output has nonsense characters added to it. For example: :( encrypts "a" as "a" using "a" as keyword \ ...
Mike's user avatar
  • 1
0 votes
1 answer
4k views

null pointer passed as argument 1

I had written this function for argument checking but it is showing this type of error vigenere.c:26:20: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/...
Rahul's user avatar
  • 252