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
2answers
226 views

Help with converting 2 or more chars to a single string

I am trying to convert two or more chars into a single string. Is this possible, and if so, how might I go about this? (BTW I am new to programming...)
1
vote
2answers
205 views

Trying to Increment Characters in a String

I am trying to increments the chars in my string (ie string x = (aaaa) all the way through (zzzz)). Is there a specific way I can use a loop to do this? I'm sorry if my question is newbie, I'm new to ...
1
vote
1answer
691 views

Pset2 - crack problem

everyone! I could use some help on crack.c problem. I tried to create a program that creates 1 to 4 random uppercase and lowercase chars, crypts them and compares them to hash. It works but it may ...
1
vote
1answer
137 views

CS50 Vigenere expected output, not a prompt for input

when I check my program, there is the "expected output, not a prompt for input" error for every input they are trying to check. however, when I am testing it, all inputs seem to be exactly the same as ...
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
61 views

I get "/opt/sandbox50/bin/run.sh: line 31: 304..." when I try to include j-- in my loop

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main (int argc, string argv[]) { //checks if argc is 2 if (...
1
vote
1answer
153 views

My code is done and working well but I still get red :( faces

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main (int argc, string argv[]) { //...
1
vote
1answer
39 views

My program doesn't work with or without command lines

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> int main (int argc, string argv[]) { //...
1
vote
1answer
35 views

Can I use functions from the library ctype.h for initialising.c in P-SET 2?

We have to give the initials all in capital letters. So can i directly use the function toupper() from ctype.h for this purpose?
1
vote
1answer
93 views

Vigenere corect encryption with weird letters at the end

so here is my Vigenere code do //Key validation { if (argc != 2) { printf("You must enter key!"); return 1; } else { for (int i = 0; i < strlen(argv[...
1
vote
1answer
109 views

What to do with the ASCII key & math?

I'm having a hard time understanding what to do with the ASCII keys & math formula. I understand that you move your plaintext over by the K amount, however, I'm not sure how to write this in code. ...
1
vote
2answers
881 views

pset2 hacker - initials.c outputs "MB" for " milo banana " expected output, but not "MB\u0000\n"

I'm working on the hacker edition of pset2 and I'm running into a problem with initials.c Here's the spec: Write, in a file called initials.c, a program that prompts a user for their name (using ...
1
vote
1answer
474 views

Vigenere key counts spaces in progression

Whenever I type plaintext into my vigenere cipher, it moves forward one letter when it encounters spaces or punctuation, even though the key does not affect those characters. How can I prevent this? ...
1
vote
1answer
455 views

Segmentation fault pset2 caesar

I have been working through the caesar code and all is well until I start playing about with the isupper function. This is where the problem is as I've been compiling and running the rest of the ...
1
vote
1answer
462 views

Difficulty with pset2 initials.c

I am having some difficulty with my code for pset2 initials.c and this is the section of code that I'm stuck on. I am trying to print the character behind the space (ie. the 'B' for Emma Brown) but I ...
1
vote
1answer
48 views

Is there some sort of method or model for executing code on paper

a[] = {45, 90, 2, 50}; for (int x=0; x < MAX-1; x++) for (int y=0; y < MAX-x-1; y++) if (a[y] > a[y+1]) { t=a[y]; a[y]=a[y+1]; a[y+1]=t;...
1
vote
1answer
135 views

Why does caesar return this?

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) { if(argc != 2) { printf(...
1
vote
2answers
1k views

initials - concatenating chars and strings?

I've learned Python in the past and I am very confused with how C handles strings. My approach for the pset2 "initials" program was to check for every character next to a space and add it to a string....
1
vote
1answer
129 views

pset2 caesar why not do it this way?

i have watched Zamyla's walkthrough several times and i wonder what if i create an array of the alphabet characters and do the cipher from that. that seems more efficient to me than doing a second ...
1
vote
2answers
1k views

pset2 , vigenere. ASCII math struggle

something weird is going on with my code. I get the first word ("Meet" with key "bacon") right, but after that, things are getting really hairy. here is my code. I would really apreciate any help, I'...
1
vote
2answers
220 views

Initials runs, but no output

I run this program in my terminal and it compiles right, but I don't quite understand why, when I type something, no output is printed and the blinking prompt with the home directory shows up again. I ...
1
vote
1answer
144 views

CERT_NOT_YET_VALID

I'm trying to run check50 on my initials.c program for PS2 but it keeps saying "uploading" and then it returns the error CERT_NOT_YET_VALID. I get the same thing actually no matter what Pset I try ...
1
vote
2answers
93 views

My caesar.c only works for values of k up to 5

I do not know why but when I run my program with k = 6 and I type z I get the weird character � Here is my code: s[i] = s[i] + k; if (s[i] > 122) s[i] = (s[i] % 26 + 78); example with 5 as k ...
1
vote
1answer
82 views

Check50 is not working on pse2! Please help

When I run check50 on caesar and vigenere, it gets stuck, blank line. No uploading, no remark, I get many DHCP commands and eventually I have to shut down the system. What is wrong? P.S I have ...
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 ...
1
vote
1answer
297 views

PSET2 Vigenere segmentation fault

I am getting nuts trying to figure out why my vigenere application gives a "Segmentation fault (core dumped)" every time I try to run it (my code is there). Can someone point out some mistakes that ...
1
vote
1answer
137 views

pset 2, Vigenere: How do I stop the keyword from looping if there is a "nonalpha" in the sentence?

My problem is that while the program loops through the sentence to be encrypted, my keyword (i.e.) bacon, doesn't stop looping when there is i.e. a space in the sentence. So instead of Sentence: ...
1
vote
1answer
121 views

Having problem in checking keyword of vigenere when it has &, (, or )

If the keyword includes &, (, or ), the program does not yell at the user for re-input, instead, comes back with the following messages for various inputs. Please note v6 is a vigenere trial ...
1
vote
1answer
695 views

pset2 vigenere doesn't work check50 with BaRFoo

I finished my vigenere and it works good with all the parameters but when I go through check50 with BaZ keyword, check50 give this answer jharvard@appliance (~/Dropbox/CS50/pset2): ./vigenere BaZ ...
1
vote
1answer
281 views

Trouble verifying the keyword in vigenere

I'm having trouble verifying the argv[1] keyword along the guidelines of the assignment. I've tried to implement an if ... else statement the checks if argc is 2 and argv[1] is alpha, if so, run ...
1
vote
1answer
482 views

Pset2 Vigenere. Works for lower and uppercase letters separately, but not for whole code

I've worked on (and dreamed about) Vigenere for a few days now, and I'm almost there. I think! If I try out my code separately for lower and uppercase letters (by commenting out the irrelevant part), ...
1
vote
1answer
638 views

Pset2 (ceasar) - check50 doesn't work

I have a big problem with pset2. I got 0.5 although both programs (vigenere and ceasar) work fine when I test them on my own, without check50. I got 100% for vigenere, and 0% for ceasar. Do you know ...
1
vote
2answers
66 views

My Coleman-Liau index gives the wrong answer

the program seems to be running fine but I don't know what went wrong in the index, it just doesn't give the right answer. #include <cs50.h> #include <stdio.h> #include <string.h> #...
1
vote
2answers
51 views

Hey. Please help me find my mistake. The number of words in my sentences is not counted properly

I tried using debugger but could not figure out where I went wrong. please help #include <stdio.h> #include <cs50.h> #include <string.h> #include <math.h> int main(void) { ...
1
vote
0answers
62 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 ...
1
vote
0answers
89 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 (...
1
vote
1answer
165 views

Pset2 Crack - works for one password 50i2t3sOSAZtk--->(lol), but not for other passwords - why?

this version of crack works for lol, and prints the following: new hash = 50i2t3sOSAZtktr [what is the 'tr' at the end???] lol for other passwords, the program never returns a decoded pw, just ...
1
vote
1answer
286 views

How can I find pythons equivilant of C's crypt function?

I am current working on 'sentimental'. However, I am having trouble finding the equivalent function of crypt used with "crypt.h" in C? I already have an algorithm for enumerating all possible ...
1
vote
1answer
112 views

Creating an array of unknown indexes. pset-2

I'm working on crack and while I've been able to iterate over an array to create possibilities to test (i.e aaaa, aaab aaac etc.) I can only do it knowing the amount of indexes the array has, I tried ...
1
vote
0answers
58 views

Getting all the possible combinations

After I have failed finishing the hacker2 brute force challenge, I have decided to try again. But I need some help with the pseudo code of storing all the possibles combination of set of numbers. For ...
1
vote
1answer
302 views

pset2 vigenere; isalpha is accepting numbers in argv[1]

I'm using the construct if(isalpha(argv[1][i]) == 0) to determine if the chars are alphabetical in argv[1] with a for loop. The program compiles, however, isalpha is not working. If I enter, for ...
1
vote
1answer
72 views

Vigenere almost working, but fails somewhere

I give up, I can't make it work. Please kindly point me to a line where I make mistake. // input validation if (argc != 2) { printf("Invalid argument. Please, try again\n"); return 1; } ...
1
vote
1answer
172 views

Initials and Vigenere pass CS50 but received 0 in Gradebook

I submitted pset2 after completing all programs, manually checking for correct functionality and ensuring all programs passed check50. However, I received 0 on both initials and vigenere. I waited 2 ...
1
vote
1answer
117 views

Vigenere print error

I've got my code to cycle through the plaintext index p and the key index. However I keep getting an error when I am printing and can't figure it out. When I use the test spec using bacon as the key ...
1
vote
1answer
87 views

right track pset 2?

To whoever is reading this, I have been working on the caesar cipher and i wrote a few stuff on gedit. I am not sure if this is correct or waaaay of. Please help me Thanks and have a great day :) #...
1
vote
0answers
75 views

Vigenere - Incorrect output

I have made a mistake in the equation for the new output. char newmsg = (((plain[i] - 97 + key[j % klength]) % 26) + 97); Can someone please give me a clue as to what I did wrong here? ...
1
vote
1answer
201 views

Code is working but the Gradebook checks are failed

My program is working correctly but all checks on the Gradebook have failed. I think problem is in printf, but what is the reason? I just print a few words and after that at new line the program ...
1
vote
1answer
736 views

Vigenere fails check50 test "encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword"

I successfully completed the Vigenere program and I was recently testing it with Check50. My problem is that there is only one test that fails, and I don't know why: :( encrypts "BaRFoo" as "CaQGon" ...
1
vote
3answers
1k views

Can't run the staff implementation

i can't run the staff implementation for any problem set, i always get the same error, it's always something like : bash: ~cs50/pset4/breakout: No such file or directory
1
vote
1answer
819 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 2
3
4 5
25