# Questions tagged [pset2]

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

1,246 questions
Filter by
Sorted by
Tagged with
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?
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;
1k views

### PSET2: CRACK vs POINTERS

SPOILERS (maybe) Hi, I have just started working on crack. I have no previous experience, at least not too much but I'm trying to grasp the logic behind this and it seems my biggest issue for this is ...
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) ...
927 views

### What does if (s != NULL) do?

According to the lecture in Week 2 and the walkthrough video "String", to make sure that the user gives us a valid string we use this condition: if (s != NULL) { //code } ...
2k views

For Pset2: Readability, I'm writing a program in C that prompts the user for text input, analyzes how many letters, words, and sentences are in the text entered by the user, and calculates the grade ...
548 views

### Pset2 Vigenere 'szz' instead of 'rby'

I fail one test case, and just the one portion of it. Expecting the following on standard out — xoqmd, rby gflkp!\n ... but received the following on standard out instead — xoqmd, szz gflkp! rby =\...
6k views

### C's DES based crypt function?

How do I use c's DES based crypt function in my crack program in pset 2
427 views

### Pset2 - Readability: How to round a .5 number depending on the 2nd digit after the decimal point

I have written a solution for readability from pset2 but I'm having problems with one of the points: :( handles single sentence with multiple words expected "Grade 7\n", not "Grade 8\n". So I ...
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 ...
347 views

### pset2 Crack - Looping through fgets

I'm trying to loop through a text file (seven lines in the file, with aaaa, aaab, aaac, etc listed) with password guesses for pset2 Crack. I am able to open the file, and iterate through the lines. ...
850 views

### PSET 2 - Can Crack be implemented for 5 characters in a more efficient way?

Okay, so I've finished the crack problem, and it runs, but since the pset2 now tells us the passwords can be upto 5 characters long, it takes about 48 minutes to get the password match for "zzzzz". ...
2k views

### Crack - launching and crypt function

I'm on the crack challenge from pset2 and I don't understand how to compile the program. When I use clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow crack.c -lcrypt -lcs50 -lm -o crack as ...
4k views

### What does " 'GetString' is deprecated" mean? How do I fix it?

I have encountered a really confusing error that deals with the "GetString();" function. I tried to google what does this error message mean but haven't had any luck finding a solution. I don't think ...
453 views

### pset2 crack segmentation fault

Program compiles, but I just can't figure out how to go trough each string length generating process without segmentation fault. I could really use some pointers please! #define _XOPEN_SOURCE #...
351 views

### Why does my vigenere not pass check50 although it gives the correct output?

When checking vigenere.c with check50, I get the following :) vigenere.c exists :) vigenere.c compiles :( encrypts "a" as "a" using "a" as keyword \ expected output, but not "a" :( encrypts "world,...
3k views

### code: string initial = toupper(name[0]); Getting an error

I am currently in pset2 and working on initials. I have been trying to implement the code string initial = toupper(name[0]); It gives an error saying incompatible integer to pointer conversion ...
683 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 ...
227 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(...
477 views

### Code Seems to Work but check50 says otherwise (pset2)

my code seems to work but check50 seems to disagree and has given me the following: :( encrypts "a" as "b" using 1 as key expected "ciphertext: b\n", not "ciphertext: b\x..." :( encrypts "barfoo" as "...
4k views

### pset2 vigenere error "incompatible integer to pointer conversion"

This is the error I get: vigenere.c:34:34: error: incompatible integer to pointer conversion passing 'char' to parameter of type 'const char *'; take the address with & [-Werror,-Wint-...
743 views

### Pset 2 - Substitution - Error - handles multiple duplicate characters in key

I have finished the substitution pset2 problem, however, there was one error when I submitted my assignment. The description of this error was handles multiple duplicate characters in key. timed out ...
297 views

### pset2 crack password does't work

I'm trying to make pset2 crack but having so much problems and my head is about to explode. Here is my code; my first error is on line 41. I never get to pass a value to the key for crypt. I'm very ...
230 views

### PSET2, crack.c Did this problem fall out of the sky from week 115? Am I overthinking this?

This is the spec: Specification Design and implement a program, crack, that cracks passwords. Implement your program in a file called crack.c in a directory called crack. Your ...
99 views

### error in initials.c when I use my own functions

I have solved the initials program in 2 different ways. In the third way, there is a bug which I am not able to clear, please help me finding it out. code: #include<stdio.h> #include<ctype....
652 views

### pset2 initials compiles and outputs correct but errors

I'm having trouble with pset2 initials.c My program compiles and passes each output test, however after each test I get "wasn't expecting "Please enter your name:" The problem states that we are to ...
264 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 ...
622 views

### Failing one test case with check50 on pset2 - encrypts "say" to "szz" instead of "rby"

encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword # Checks 0 Running... clang -o vigenere vigenere.c -lcs50 -lm. ✔ 1 Expecting an exit code of 0. ✔ 2 Running... ...
83 views

### pset2/crack/(Memory issue)

If I run this code for the first time it gives me the desired output. But on the second run, I don't get the desired output. It seems like memory is not given free. #include <stdio.h> #include &...
203 views

### pset2 Initials Design Improvements

I was hoping you might be able to help me improve the design of my code. I've solved the initials problem, and it passes check50 on both normal and hacker edition (the hacker edition was incidental), ...
2k views

### Not able to understand what I need to do in pset2 (crack.c)

I have completed all problems in psets 0, 1, 2 comfortably except for the last problem. Crack.c (more comfortable version). I read the cs50 crack.c page and I also watched the walk through twice but ...
3k views

### Implicit declaration of function 'topper' is invalid in C99

I am currently working on pset2 in CS50 and am having trouble with initials.c The compiler does not recognise 'toupper', and I use '#include ' at the top. I just updated everything, so this seems to ...
768 views

### pset2 (vigenere) - Check50 error problems

I'm stuck on an issue with my code. After completing my code and making sure it works as should, I run check50 and this is what I get; jharvard@appliance (~/Dropbox/pset2): check50 2014/x/pset2/...
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 ...
65 views

### Too much whitespace in vigenere.c, style50 error in pset2

The Program has no errrors when checking with check50 but when i check vigenere.c with style50 by: style50 2015.fall.pset2.vigenere vigenere.c it gives the following error: :( 84:20 Too much ...
9k 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 ...
240 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 ...
3k views

### pset2: Crack takes a lot of time

I take an average of 20 minutes to crack the password and some people are saying it can be done in less than 30 seconds, I have been trying to find out why my code takes that much time but I can't. #...
63 views

### vigenere sometimes prints extra characters at the end of ciphertext in an unpredictable pattern

Check50 yields 2 error messages (the rest is correct): :( encrypts "a" as "a" using "a" as keyword output not valid ASCII text :( encrypts "world!\$?" as "xoqmd!\$?" using "baz" as keyword output not ...
156 views

### Cs50's vigerene encrypting problem

My code complies well but encrypts the text in the wrong way.Could someone help me find the problem? any help will be appreciated here is my code: #include <stdio.h> #include <cs50.h> #...
308 views

### Unexpected outputs - initials.c

it's nice to be here! In initials.c in pset2, I am able to extract and capitalize (if necessary) the first letter of the inputted name string, iterate through the string and extract and capitalize ...
4k views

### string comparison & crack.c

I've been working on the pset2 hacker problem and decided to decompose a problem by creating subtasks. Anyway, the first part was to simply compare two crypted strings (at the moment, just one letter ...
3k views

### Vigenere cipher coding drama!

your help is appreciated and please feel free to critique my coding approach. My concern is, not only that the code isn't working, but that I maybe complicating this more than it needs to be. Working ...
790 views

### Vigenere Cipher Doesn't Work Properly

I have been trying for way too long to make my Vigenere cipher work, but now I am so confused I don't even know what I am doing. I need some guidance in what it is that I am doing wrong. When I ran ...
111 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; ...
477 views

### cs50/pset2/vigenere: Code works but check50 rejects 2 item

check50 message: https://cs50.me/checks/c053757544cd74cafb77554759754b8ee4ee37a8 The code doesn't encrypts "a" as "a" using "a" as keyword. It adds a wierd character in the end and I don't know why. ...
218 views

### Easiest method to organize code

I'm just finished the entire cs50 course (yay), except the final project, and I'm ready to start submitting all of my psets. Before I submit, I'm going to proofread all my code and simplify/style it ...
840 views

### Cs50 problem set 2 Initials

everyone! I have one problem with code initials. It correctly runs but after check50 I've got some issues , among them- ***\ expected output, but not " \u0000\n"***that I can't fix.Help me,please) #...