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
22k 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 ...
  • 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;
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 ...
2 votes
1 answer
345 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(...
1 vote
2 answers
53 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("...
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 ...
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 //...
0 votes
1 answer
110 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 ...
0 votes
1 answer
862 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" ...
  • 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?
  • 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 ...
  • 35
2 votes
1 answer
289 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 ...
  • 203
1 vote
2 answers
176 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 ...
1 vote
1 answer
904 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. ...
  • 11
1 vote
1 answer
169 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 ...
  • 113
1 vote
1 answer
456 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 ...
1 vote
1 answer
169 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 + ...
  • 13
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 ...
  • 101
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 ...
0 votes
1 answer
68 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 = ...
0 votes
1 answer
397 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 ...
0 votes
1 answer
684 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 ...
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> #...
  • 11
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) ...
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 ...
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 ) ...
  • 23
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/...
  • 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 ...
  • 171
0 votes
1 answer
285 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 \ ...
  • 1
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...............
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, ...
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 ...
0 votes
2 answers
189 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, ...
-1 votes
1 answer
340 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 ...