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
21k 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 ...
user avatar
  • 1
5 votes
4 answers
7k 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
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
2 votes
1 answer
314 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(...
user avatar
1 vote
1 answer
285 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 ...
user avatar
1 vote
2 answers
49 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("...
user avatar
0 votes
1 answer
120 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 //...
user avatar
0 votes
1 answer
109 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 ...
user avatar
0 votes
1 answer
854 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" ...
user avatar
  • 3
9 votes
4 answers
9k 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?
user avatar
  • 305
2 votes
1 answer
284 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 ...
user avatar
  • 203
1 vote
1 answer
884 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. ...
user avatar
1 vote
1 answer
164 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 ...
user avatar
  • 113
0 votes
1 answer
89 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 ...
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 ...
user avatar
  • 35
1 vote
3 answers
6k 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 ...
user avatar
  • 101
1 vote
2 answers
140 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 ...
user avatar
1 vote
1 answer
454 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 ...
user avatar
1 vote
1 answer
168 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 + ...
user avatar
  • 13
0 votes
1 answer
66 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 = ...
user avatar
0 votes
1 answer
94 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) ...
user avatar
0 votes
1 answer
318 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 ...
user avatar
0 votes
2 answers
188 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, ...
user avatar
0 votes
1 answer
187 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...............
user avatar
0 votes
1 answer
669 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 ...
user avatar
0 votes
1 answer
390 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 ...
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 ) ...
user avatar
  • 23
0 votes
1 answer
168 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 ...
user avatar
0 votes
1 answer
92 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> #...
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, ...
user avatar
0 votes
1 answer
272 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 \ ...
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/...
user avatar
  • 264
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 ...
user avatar
  • 171
-1 votes
1 answer
339 views

Ignoring Non-Alphabetical chars in Vigenere [duplicate]

I do not control?? do so each independent encryption if uppercase text and key do this if key lowercase text and do this if uppercase - lowercase text and key do this if lowercase - uppercase text ...
user avatar