Questions tagged [pset2]
The problem set for Week 2 continues with the C programming language used in problem set 1.
1,274
questions
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?
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;
5
votes
1
answer
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 ...
4
votes
2
answers
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)
...
4
votes
3
answers
1k
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
}
...
3
votes
4
answers
2k
views
Pset2 Readabilty: Why are my grade levels calculating incorrectly?
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 ...
3
votes
1
answer
592
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 =\...
3
votes
1
answer
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
3
votes
1
answer
532
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 ...
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 ...
3
votes
1
answer
360
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. ...
3
votes
1
answer
852
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".
...
2
votes
1
answer
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 ...
2
votes
1
answer
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 ...
2
votes
2
answers
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
#...
2
votes
1
answer
353
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,...
2
votes
2
answers
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 ...
2
votes
1
answer
802
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 ...
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(...
2
votes
2
answers
549
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 "...
2
votes
1
answer
951
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 ...
2
votes
1
answer
5k
views
Checking to see if the contents of a string is an integer
Currently I am working on Caesar and validating the user inputs. The argument count section works fine. However, I can't find a way to compare the value in the vector argument string (argv[1]) to see ...
2
votes
1
answer
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-...
2
votes
1
answer
299
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 ...
2
votes
2
answers
238
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 ...
2
votes
1
answer
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....
2
votes
2
answers
654
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 ...
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 ...
2
votes
1
answer
623
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... ...
2
votes
1
answer
85
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 &...
2
votes
1
answer
208
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), ...
1
vote
1
answer
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 ...
1
vote
1
answer
4k
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 ...
1
vote
2
answers
11k
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 ...
1
vote
2
answers
770
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/...
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
...
1
vote
3
answers
62
views
Segmentation error on pset2 substitution
I'm trying to work on "substitution" problem set, but I'm getting an error of "Segmentation Fault" when I run the program below:
In this part of the program I just want to check if ...
1
vote
3
answers
71
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 ...
1
vote
1
answer
3k
views
Pset2 Vigenere: Control reaches end of non-void function
I´m trying to solve this pset but I got stuck with function declaration. I did everything according to the tutorial but the clang keeps showing an error: "control reaches end of non-void function" on ...
1
vote
1
answer
276
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 ...
1
vote
1
answer
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.
#...
1
vote
1
answer
66
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 ...
1
vote
4
answers
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>
#...
1
vote
2
answers
313
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 ...
1
vote
1
answer
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 ...
1
vote
1
answer
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 ...
1
vote
4
answers
801
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 ...
1
vote
1
answer
684
views
CS50 pset2 substitution - timed out while waiting for program to exit
I tried all the provided examples on the pset2 site, and I got all of them correct. But when I used check50 to check my code, it said: "timed out while waiting for program to exit" for some ...
1
vote
2
answers
44
views
CS50 Readability compile error
Im trying to compile the program but keep getting this error message below:
Can someone tell me what this means please. The carat arrow is supposed to be pointing at "char" and "ch&...
1
vote
1
answer
139
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;
...