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
1
vote
1answer
140 views

Vigenere -Isalpha only checking first char of key

When checking the command line argument in Vigenere.c to see if it contains any non-alphabetic characters, I can't get my for loop to iterate past the first character. I have read all of the posts on ...
1
vote
1answer
97 views

Pset2- Vigenere: returning error on BaRFoo only

I am trying to complete vigenere's cipher by the end of tonight before I am shortly without internet. I have been working on this one error for several hours and cannot figure out how to fix it. The ...
1
vote
1answer
2k views

Is it possible to re-submit the a problem-set and get another grading? [duplicate]

I kinda did wrong in Problem2 Code and when I fixed it, I re-submitted, in that case, am I gonna get a new grading?
1
vote
2answers
120 views

Line length too long

I just finished the Caesar program and it works, but when I run style50 it complains that this line is too long: if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && ...
1
vote
2answers
84 views

I truly confused on why ceaser won't work,

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
1
vote
1answer
58 views

Pset2 Caesar - Segmentation fault error

First off, I will show my code: int main(int argc, string argv[]) { if (argc != 2) { printf("Wrong command line arguments\n"); return 1; } else { ...
1
vote
1answer
146 views

Check50 for caesar, pset2 returns an error "Not valid ASCII text" twice, even though it encrypts correctly for the same text used in check50

Okay, the code is given below (forgive me if there are too many comments!!). Please help!! Code: //the objective of the program is to create a simple encryption of the text inputted by the user with ...
1
vote
1answer
4k 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 ...
1
vote
1answer
190 views

vigenere output "incompatible pointer types"

I'm trying to solve pset2 vigenere, but I'm having some troubles. I'm using two functions to adapt the key to the text and then to apply the cipher. When I run the last function, I can't get any ...
1
vote
1answer
152 views

Pset2 can't crack stelios password

My solution for Pset2 crack works for every password except for stelios's. I can crack other 5 character passwords (e.g., ABCDE, etc.), but for some reason, my code runs for 60m9.563s when trying to ...
1
vote
1answer
61 views

Caesar compiles, but gives the wrong cyphertext

Hi guys, I'm struggling with my caesar program. I believe I've touched on every specs requirements, but the expected result isn't here. For instance, using a key of 1, "ABC" becomes "C". Please see my ...
1
vote
1answer
119 views

Pset2 - Vigenere fails check50 with "expected exit code 0, not 1"

I'm at my wits' end. My code for vigenere compiles fine using make vigenere within CS50 IDE. However, when I run check50, I get this: :) vigenere.c exists. :( vigenere.c compiles. expected exit ...
1
vote
1answer
406 views

pset2 crack - stelios only password I can't crack

My crack code seems to be able to crack every single one of the hashes from pset2 except for stelios', which has hash 50nq4RV/NVU0I Does this pw have anything particular not included in the other ...
1
vote
2answers
180 views

Pset2 Caesar is not printing non-alphabetic characters

My Caesar for problem set 2 seems to encrypt my plaintext correctly. My problem is just that it won't print any non-alphabetic characters. For instance, when my plaintext is "hello, world" and the ...
1
vote
3answers
2k views

PSet 2: Crack - Faster Methods?

I've just finished crack of problem set 2. My solution, though, seems quite ugly to me, as it was just some mindless brute force (in which I frankly struggled with strings for a while). E.g. to ...
1
vote
2answers
85 views

Pset2 Caesar struggle but i gotta do it im from Rome

Ave thanks in advance for your help total newbie trying to make pset2 caesar. here is the error caesar.c:14:1: error: expected identifier or '(' {{ ^ 1 error generated. here is the code #include ...
1
vote
2answers
349 views

Pset2 - Caesar (less comfortable) wraparound problems

if (isalpha(plain[i])) if (isupper(plain[i])) { printf("%c", ((plain[i]-65) + k) % 26); } if (islower(plain[i])) { printf("%c", ((plain[...
1
vote
1answer
136 views

pset2 crack - conditional is not working

I'm trying to get crack.c to print out the key used in the crypt() function if the output from crypt() is the same as the user-inputted hash. To test this out, I've pre-generated a hash to use in ...
1
vote
2answers
313 views

pset2, Caesar. Can't pass testing [duplicate]

I have a problem with check my code CS50, my code is below: #include <cs50.h> #include <stdio.h> #include <string.h> //desribe of values //int i - number of arguments //int n - ...
1
vote
2answers
596 views

Usage of Crypt Function?? Correct usage?

I am using the crypt function like this. Is it correct? string lol = crypt(plaintext, salt); Here plaintext and salt are both character arrays(strings). Am I using this function correctly? When I ...
1
vote
2answers
103 views

CS50 PSET2 VIGENERE problem with key lenght in loop

I have a problem printing the word "world". My code is the following (EDIT): #include <cs50.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h&...
1
vote
2answers
105 views

Finished vigenere, but it fails to work as it should

*UPDATE: Actually, I can't understand a thing now. Let's take an example from check50. Our program should encrypt "world, say hello!" with a keyword "baz". It expects "xoqmd, rby gflkp!" as a correct ...
1
vote
1answer
222 views

pset2 caesar, argv[1]

Ok I'm consistently encountering a peculiar issue that I can't get my head around. this loop should return an error if there is a character other than a digit. When I give a character other than a ...
1
vote
1answer
256 views

pset2: "initials" string usage problem

So people told me that I can't use an array of strings and try to output just the first character of every single string like in this code for example: #include <stdio.h> #include <cs50.h&...
1
vote
2answers
177 views

CS50 vigenere.c works for lower but not upper case letters

The following is my code, I'm not sure where I went wrong with my code, but when I run it, it seems to work for lower case letters but not uppercase. This isn't the full code, due to academic honesty, ...
1
vote
1answer
273 views

Reading a line from a file

I am doing pset2 hacker edition. I am trying to read a line of string from "/usr/share/dict/words" as per pset specification using fgets() function but instead of reading the full line it is only ...
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
1answer
709 views

Check50 fails but my code works! [duplicate]

I have done my pset2 but my code fails check50 even though the code is correct and encrypts the text correctly. Here is the check50 output: :) caesar.c exists :) caesar.c compiles :( encrypts "a" as "...
1
vote
1answer
24 views

Programs will run but can't be edited

Programs like mario and greedy that I've completed will run but now the code can't be edited. I've been working on caesar and the part I've completed runs, but when I go back to gedit to edit the code ...
1
vote
2answers
95 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
1answer
395 views

What am I missing ? (pset2, readability)

The problem is that when i run check50 cs50/problems/2020/x/readability into the terminal, it says :( handles questions in passage Cause expected "Grade 2\n", not "Grade 3\n" Log ...
1
vote
1answer
283 views

I have "handles non-numeric key timed out while waiting for program to exit" problem inPset 2 and I can't solve it

here is my code: #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #include <stdlib.h> int main(int argc, string argv[]...
1
vote
1answer
33 views

Any advice on getting the CS50 IDE to read my closing parentheses, brackets and curly brackets

I've been trying to work on the Caesar problem in CS50 and keep running into the same problem of it not reading the second parentheses of my printf code. When I try to test it without the printf ...
1
vote
1answer
392 views

pset 2-substitution-error handles multiple duplicate characters in key timed out while waiting for program to exit

Im working on substitution from pest 2 and I'm getting everything approved except for the last message: handles multiple duplicate characters in key timed out while waiting for program to exit Below ...
1
vote
1answer
399 views

PSET2 Substitution - Output seemingly correct, fails check50 (null character?)

thank you for your help in advance! I can't wrap my head around what's wrong with my code as the output is (seemingly) correct. I suspect it has something to do with the null character. #include <...
1
vote
2answers
58 views

PSET 2 Vigenere - only getting symbols as output

So far in Vigenere i've gotten to the point with a single character key, and when I tried to test it, everything works except my output is entirely ����. Here is my code for the shift function and ...
1
vote
2answers
106 views

cs50 week 2 crack compiles but doesn't do anything

Any advice on why the code isn't running? Yet it compiles? Code Link: https://pastebin.com/XMhgJ49k Thanks!
1
vote
1answer
267 views

Pset2 Crack problem

I wrote a code for the crack problem. To test the code I set hpass (stands for hashed password which is the input the user is going to enter) to crypt("AB","50")(see line 15). The expected output of ...
1
vote
1answer
19 views

Vigenere.c has some problem in accepting alpabetic as a key

when i give an input of ./vigenere abc it doesn't accept and its printing key must be alphabetic.where have i gone wrong.would anyone explain in brief? and how do i correct it? Please help me out.! ...
1
vote
2answers
98 views

Refactoring Pset1 Greedy Modulo

I've got Pset 1, 'Greedy' working, I just think I can refactor it better. How can I get rid of ints a, b, c and d? a = amount /25; amount = amount % 25; b = amount /10; amount = amount % 10; c = ...
1
vote
1answer
120 views

Pset2: Copying string contents

I just can't seem to get this right. The example in the week 2 short Arrays is as follows: int foo[5]{1,2,3,4,5}; int bar[5] for(j=0;j<5;j++) { bar[j]=foo[j]; } This does not seem to work with ...
1
vote
1answer
265 views

PSET2 (Crack) - Comparing 2 hashes with strcmp() always returns 0

So, this isn't the full solution to the problem, I'm currently just messing around with crypt, I've got the following code: #define _XOPEN_SOURCE #include <unistd.h> #include <stdio.h> #...
1
vote
1answer
47 views

Pset2 - Vigenere - Encypts all variations of "barfoo" as "ca\..." (no case issues)

This is my first question on Stack Exchange. I had a few different issues with this problem but I felt I'd finally sorted them out until I ran into this. I've been working for a number of hours today ...
1
vote
1answer
504 views

End program by returning exit code 0 from bool function

so, for pset2 crack task i've generate a password, then encrypt this password and a salt to some result by result = crypt(pass, salt); After i want to compare result with hash, so i implemented a ...
1
vote
2answers
2k views

error: unused parameter 'argv'

I am writing this simple code for checking if the user has entered the key or not. If not I want to return 1 and show an error msg. Below is the snapshot of my code which I am using. I am getting the ...
1
vote
1answer
382 views

pset2 Caesar - How to properly implement modulus operator

I understand the necessity of using the modulus operator to compensate for plaintext characters that would surpass Z or z respectively, but I cannot seem to wrap my head around its particular syntax. ...
1
vote
1answer
51 views

pset2 Initials - negative index

I finished the Initials (more comfortable) problem, but when trying to detect initials, I'd like to avoid negative indeces. Here's what I used for the detection of initials, if it's not a space at ...
1
vote
1answer
131 views

Help with understanding the wrap-around method for Vigenere Pset

I'm having troubles with implementing the wrap around method needed for passing this problem. As you will see, my code so far encypher a number of plaintext letters as equal as the number of the "key" ...
1
vote
2answers
90 views

pset2 vigenere problems

I am kind of stuck with my Vigenere Code so far... and i really feel like don´t know how to work it out from here! Any kind of advice is much appreciated, or i might be stuck here forever :( #include ...
1
vote
1answer
152 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 ...

1
2
3 4 5
25