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
1answer
17 views

What's wrong with my code here?

it's not printing what i expecting when i write (b) as key and (m) as plaintext for checking it prints (n) but more than expected and i don't know what i'm missing any help would be appreciated, here'...
0
votes
1answer
17 views

I have multiple issues with my code

after rewriting my code again i faced some proplems, when i compile it with 'a' or other key it's not printing anything, and i'm checking if user not providing plaintext it should print messege but it ...
0
votes
1answer
8 views

what's wrong here? i get an segmentation fault error and am i at the right direction?

int keyvalue = 0; int n = strlen(argv[1]); char cipher; for (int i = 0; i < n; i++) { keyvalue++; } for (int i = 0, s = strlen(...
0
votes
1answer
20 views

when i run ./caesar it give me strange error i don't understand

caesar.c:9:20: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/include/stdlib.h:105:33: note: nonnull attribute specified here UndefinedBehaviorSanitizer:...
0
votes
1answer
45 views

pset 2 CS50 2019 Vigenere

I tried checking other Vigenere solutions, but I seem to find no way to solve the problem on the loop with text[u] and argue[1][i], I just can't make after the last ith valeu to go back to 0 ith valeu?...
0
votes
1answer
41 views

I can't get my Vigenere code to skip spaces and punctuation, I don't know why

#include <cs50.h> #include <ctype.h> #include <stdio.h> #include <string.h> int shift(char c); int main(int argc, string argv[]) { // Checks to make sure user enters ...
0
votes
1answer
19 views

I can't work out what is wrong with my code - I think I am not indexing into the key

#include <cs50.h> #include <ctype.h> #include <stdio.h> #include <string.h> int shift(char c); int main(int argc, string argv[]) { // Checks to make sure user enters ...
0
votes
1answer
16 views

I keep getting an error: incompatible pointer types passing 'string' (aka 'char *') to parameter of type 'string *' (aka 'char **')

#include <cs50.h> #include <ctype.h> #include <stdio.h> #include <string.h> int shift(string argv[]); int main(int argc, string argv[]) { // Checks to make sure user ...
0
votes
1answer
16 views

Error message: 21:9: error: expected expression else

I keep getting the above error: #include <cs50.h> #include <ctype.h> #include <stdio.h> #include <string.h> int main (int argc, string argv[]) { if (argc != 2) { ...
0
votes
1answer
22 views

Caesar - Validating key using isdigit

I keep getting this error: caesar.c:17:13: error: subscript of pointer to function type 'int (int)' if (isdigit[i] == 0) This is my code: #include <cs50.h> #include <ctype.h> #...
0
votes
1answer
18 views

Pset2 Vigenere some flaws in the code

I somehow managed to come up with this code to vigenere but it gives me 9/11 with check50. It encrypts it badly when using the keyword BaZ and BAZ. Why is that please? And also I think I was supposed ...
0
votes
1answer
14 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 ...
0
votes
1answer
27 views

I get 5/11 on check50 after submitting vigenere, even though my actual output and expected output are the same. Can someone please help me?

Here is my code [removed code per academic honesty guidelines] And here is the link to the check50 if it can be helpful https://submit.cs50.io/check50/b2fae7703d9488a6c2737ebd8aa7319b95daefbb
0
votes
1answer
43 views

My solution to Pset2's Caesar works but I only got 40% on it. Why?

I worked my way through Caesar as well as Vignere in PSet2. I got a score of 99% for Vignere but only 40% on Caesar, which is really strange as I worked off of Caesar for Vigenere.. If anyone could ...
0
votes
1answer
20 views

PSet 2: How do I ensure that the entire string is checked before printing a statement

In this problem set, we are supposed to obtain one argument (which comprises of digits), failing which, the user is prompted with a message, Usage: ./caesar key. I have attached the problem statement ...
0
votes
1answer
36 views

PSet 2: Code successfully compiled but does not meet desirec requirement

In this problem set, we are supposed to obtain one argument ( which omprises of digits), failing which, the user are prompted with a message, "Usage: ./caesar key". I have attached the problem ...
0
votes
1answer
27 views

CS50 Problem Set 2 Code Not Fully Executing

I am trying to get the code to check that: 1) Only a numerical argument is passed through 2) If a non-numerical, number is pass through, an error message is revealed to the user. Here are the ...
0
votes
0answers
34 views

CS50, pset2, crack, suggested dictionary file

I am taking cs50 on edx and I am currently on pset2, crack. I want to find a dictionary file that has a fair (maybe over 50,000?) amount of words in it to encrypt and compare them with the hashed ...
0
votes
0answers
50 views

PSET 2 - Crack - A way to improve?

To give a bit of context I am taking CS50 through EdX in 2019. I worked on pset2 (crack) the last few days. I got it "right" though I wonder if there are some ways to improve (1) the efficiency and (...
0
votes
1answer
44 views

UndefinedBehaviorSanitizer:DEADLYSIGNAL ERROR The signal is caused by a WRITE memory access

My goal is to figure out how to append to a new string. Why does top code work but bottom code gives error? Aren't they the same? Try it out. #include <cs50.h> #include <string.h> #...
0
votes
1answer
40 views

Validation bug on caesar, repeating loop error for more than one digit key

After spending many hours on caesar, I have restarted from nothing several times and think my program is able to correctly validated the key given by the user. The problem is that my validation only ...
0
votes
2answers
48 views

pset 2 need help validating key on argc argv

how to defend against argv[1] with alphabet input? I can defend against: ./caesar 1 2 3 and ./caesar -123 BUT NOT ./caesar abcd AND ./caesar 12ab My code is as follow: int main(int argc, ...
0
votes
1answer
34 views

What does argc and argv have to do with cryptography? Why are we learning about these arguments?

I understand what these arguments do--take inputs before the program starts to in some way influence the program. But they seem to have been shoe-horned into the lecture. David moves on from this ...
0
votes
1answer
67 views

PS2 Caesar having trouble validating key

So far I've only gotten to the part where the code should check to see if the key is only digits. #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> ...
0
votes
2answers
37 views

Week 2 CRACK: Erratic behavior with NULL '\0' when printing combinations of letters

I want to iterate through all possible combinations of the alphabet, including single letter outputs. For this purpose I included the use of '\0' so the first print out in the iteration is the sigle ...
0
votes
1answer
68 views

Validating the key in PSET2 caesar?

int main( int argc, string argv[]) { if(argc ==2) { for(int i = 0, n = strlen(argv[i]); i < n; i++) { if(isdigit(argv[1][i])) { ...
0
votes
2answers
45 views

PSET2 Vigenere: Output bug, keyword loop going over strlen of key

I am having an issue specifically with the second for loop (under "//iterate over key inputs" comment). The counter j is going over the strlen of argv[1], and thus feeding a wrong input to my shift ...
0
votes
0answers
55 views

Iteration over permutations - pset2: crack

To do 'crack' in pset2, I want to iterate over every permutation of letters of an alphabet in an array of a certain size n (n=3 in the code below). A possible solution would be using n nested loops. ...
0
votes
0answers
78 views

Vigenere Output bug

I feel that I'm making steps that shouldn't be done and ignoring some handy steps that need to be used, I'm trying to validate my code step by step but I spent to much time trying to solve vigenere ...
0
votes
1answer
76 views

Help with weird bug in pset2 vigenere

After finishing most of the program, for some reason when check50 attempts to encrypt BaRFoo using keyword BaZ as well as the other attempts for the variations of barfoo and "hello, world", my code ...
1
vote
2answers
40 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 ...
0
votes
1answer
81 views

PSET 2 Crack: Getting salt from argv[1]

I think I might be misunderstanding some basic things about strings because I'm really struggling to get the salt in crack. I'm getting compile errors from the below code. I've also tried making the ...
0
votes
1answer
72 views

Problem with Pset2 submission vigenere

I just wrote the program for cs50 pset2 vigenere problem. It ran perfectly when I tried to run it, with expected output. But on submitting, cs50.me check50 shows that my program does not show the ...
0
votes
1answer
136 views

How do I validate a key in Caesar?

I'm having difficulties in validation step in Caesar. My logic here is to pass through each digit and check if it is a number character and if not, abort. If they all are, it will convert each ...
0
votes
1answer
41 views

pset 2 caesar help!

am having trouble printing the correct ciphertext, code is rather lengthy for sure but will appreciate it a lot if anyone can tell me what's the problem here! For example with a key of 1 and a ...
0
votes
1answer
111 views

pset2: vigenere.. Getting same output as the staff's solution, but still gets the score 2 out of 5.. Could some one guide me to the problem?

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int shift(char c); int main(int argc, string argv[]) { // Check that ...
0
votes
1answer
69 views

Pset2 - Shifting characters in String but not getting the correct answered

i am attempting Vigenere on CS50 Pset2. I am creating a new array with same length as keyword to shift to its digit counterpart. However i am not getting the correct answer, any idea what is the ...
0
votes
2answers
32 views

Pset 2 - String is unitialized, initialize the variable to silence this warning

I am working on Caesar cipher on CS50 Week 2. I have generally wrote most part of the code but the final error message which i have not debugged was the initalizing of the string at the end. How do ...
0
votes
2answers
39 views

Crack.c Error in 2 passwords

For pset2 crack, I have managed to crack 10 of the 12 passwords given, but, the other 2 passwords are not getting cracked. Any help would be appreciated. Code: //Cracks password encrypted using ...
0
votes
1answer
23 views

PSet2 why isn't this providing output

This segment of code only prints out blank lines. Key is the correct integer, but I must be handling the array of characters incorrectly. Thoughts? int key = atoi(argv[1]); for (int i = 0, c = ...
0
votes
1answer
146 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 ...
0
votes
1answer
31 views

Vigenère spitting out random strings

My vigenère is spitting out random strings. For example, here is a test I got from my terminal ~/pset2/ $ ./vigenere a plaintext: a ciphertext: G ~/pset2/ $ And my code is here. I suspect that ...
0
votes
1answer
46 views

In Vigenère, is the key case sensitive? SOLVED

Is the key in Vigenère case-sensitive? It doesn't say and I'm confused.
0
votes
1answer
61 views

crack.c: No response 😒

When I run my crack.c, the program never responds. It just sits there and wastes time. I even tried debugging it on the CS50 IDE, and it was normal. Here is my code: #include <cs50.h> #include &...
0
votes
1answer
118 views

crack.c: UndefinedBehaviorSanitizer:DEADLYSIGNAL --SOLVED--

When I run my code: #include <cs50.h> #include <stdio.h> #include <crypt.h> #include <string.h> string crack(string hashed); string deleteAll(string s, char target); // ...
0
votes
1answer
42 views

Pset 2 Vigenere

For capital letters the key seems to be behind my -6. Such that A is -6 and F is zero. :(
0
votes
1answer
35 views

pset2 Vigenere - output overwriting “ciphertext”

I'm stuck (apologies if I just didn't find the answer to this - I did read a number of answers and didn't see a solution to this problem). I have a line in my code to print "ciphertext:" before the ...
0
votes
2answers
96 views

pset2 crack: Takes too long

My code takes like 1-2 minutes to execute, and the result is always Killed. Here is my code: #include <cs50.h> #include <stdio.h> #include <crypt.h> #include <string.h> ...
0
votes
1answer
37 views

my crack.c actually works, but doesnt give away the key! Pset2

I am trying to figure out how to solve the crack problem from pset2, everything works fine with compiling but when I try to crack the hash from the example 50cI2vYkF0YU2 which is Zamayla's ...
0
votes
1answer
303 views

CS50 pset2 vigenere problem getting the shift

Problem with the shift value function ## Hi, Could anyone please take a look at the code below and help me figure out where it goes wrong. I think the problem is with the shift_value. The code ...