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
2answers
19k 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 ...
5
votes
4answers
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
3answers
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
1answer
240 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
2answers
48 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
1answer
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
1answer
828 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" ...
0
votes
1answer
117 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
1answer
107 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 ...
9
votes
4answers
8k 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?
2
votes
1answer
266 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 ...
1
vote
1answer
824 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. ...
1
vote
1answer
153 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 ...
0
votes
1answer
84 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 ...
3
votes
1answer
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 ...
1
vote
1answer
448 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
1answer
160 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 + ...
1
vote
2answers
98 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
3answers
5k 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 ...
0
votes
1answer
377 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
1answer
651 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
1answer
55 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
1answer
315 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
2answers
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, ...
0
votes
1answer
166 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
0answers
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 ) ...
0
votes
1answer
88 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
1answer
185 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
1answer
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/...
0
votes
1answer
260 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 \ ...
0
votes
1answer
333 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
1answer
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 ...
0
votes
1answer
89 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> #...
-1
votes
1answer
335 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 ...