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

String being replaced by garbage before being printed

I have this code: #include <cs50.h> #include <stdio.h> #include <string.h> string increment_str(); int main() { string s = increment_str("xyz"); printf("String: %s\n", s); }...
0 votes
1 answer
115 views

PSET 2 ----CAESAR

I am struggling in Caesar in Pset2. I am not being able to understand what is the function of argc and from where will the code pickup alphabets? That is, how will the software understand that "b" ...
0 votes
1 answer
51 views

unexpected output vigenere

I am getting an odd output and can't figure out why. I have tried using a debugger and tried different ways of approaching the problem. int main(int argc, string argv[]) { if (argc == 2) { ...
0 votes
1 answer
61 views

How do I return my array of chars in a function to a string in main()

I'm having difficulty implementing the two sections of code for the caesar pset. Individually I have made both my main() and my rotating algorithm caesar() work, but am having trouble combining them, ...
0 votes
1 answer
71 views

CS50 Week2 capital letters bug

I'm trying to complete the vigenere code assignment but sadly, despite it seemingly working great with lowercase letters, it completely bugs out with capital letters. This is how it looks like with ...
0 votes
0 answers
16 views

PSET2 Caesar: Ordered Comparison Between Pointer and Integer Error

I have not even learned pointers yet, I am confused on this error message. For context, the full message is as follows: caesar.c:46:36: error: ordered comparison between pointer and integer ('string' ...
0 votes
1 answer
13 views

Readability can't compile. Error : expected '(' after 'if'

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <math.h> int main(void) { //prompt user for a string string text = ...
0 votes
1 answer
75 views

Pset2 Readability undeclared identifier error message

I am attempting to make my program but everytime I try, it tells me I have not identified my variable "i" eventhough I identified it as an integer above. Does anyone know what I'm doing ...
0 votes
1 answer
98 views

Road block again!!! Caesar pset2

What does this mean?: ":( handles lack of argv1" My code passed all the checks except for this one.
0 votes
1 answer
456 views

Pset2 (Caesar). Runtime error: load of null pointer of type 'char'

Problem with segmentation. I can compile the program, but can't run. Questions about segmentation fault were asked many times, but I still don't know. I think problem with command-line argument — I ...
0 votes
1 answer
53 views

Pset2 Caesar Hail dont know how to encrypt the plaintext

plz help me refine my code thx!! https://raw.githubusercontent.com/check50/davil3388/cs50/2017/fall/caesar/caesar.c?token=Aehv0R6qUjbNWPi_rOMKjS7ChP3tSlW1ks5aSK8MwA%3D%3D
0 votes
1 answer
218 views

Pset2 Caesar variable problem

I can't figure out whats wrong. Here's my code: //argc and argv allow to for users to input data before the program runs. int main (int argc, string argv[]) { //Do-while loop to ensure user ...
0 votes
1 answer
391 views

CS50 PSET2 code will not compile

I would appreciate any help that could be given with my code below (+ error codes below that): My code will not compile and the primary error apparently is an "undeclared identifier" refering to ...
1 vote
3 answers
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
0 votes
1 answer
175 views

I need help using isupper/islower and converting ASCII to Alphabet for Caeser PSET2

Beginner coder here. I'm working my way through caeser but can't seem to understand how I would implement isupper/islower to preserve case, or change ASCII to alphabet. Here is my code so far and it ...
0 votes
1 answer
113 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
1 answer
115 views

problem with pset 2 initials (more confortable)

im having a problem with initials (More Confortable) in Pset2. The ckeck50 software outputs this: : ( outputs "MB" for " milo banana " \ expected output, but not "MB\u0000\n" But when i try to run ...
0 votes
1 answer
211 views

pset2 Vigenere: Problems Applying Key & Case

for (int i = 0, n = strlen(p); i < n; i++) { if (isalpha(p[i])) { if (isupper(p[i])) { char stringshifttext = ((((p[i] - 'A') + (k[i % strlen(k)] - 'A')) % 26) ...
0 votes
1 answer
249 views

Problem with caesar cipher encryption

I'm trying to solve pset2 Cesar encryption.Everything seems fine and encryption is working but when I hit check50 I get errors: :( encrypts "a" as "b" using 1 as key expected prompt for input, ...
0 votes
2 answers
317 views

crypt key char concatenation (pset2/crack)

I have created a series of for loops to iterate through every combination of a 4 letter long password (i j k l). I wish to enter each iteration into the crypt function but what I have been trying has ...
0 votes
2 answers
70 views

On running as ./a.out <keyword>

On running as above the program shows segmentation fault. Why is it so? The program is for pset2 vigenere.c . What I am doing is storing the key in a string and then storing the integer value of key ...
0 votes
1 answer
85 views

Please help!! pset 2 cannot successfully create a loop for "k"

#include <cs50.h> #include <stdio.h> #include <string.h> int main (int argc, string argv[]) { string k= argv[1]; string p = argv[2]; if (argc==2) { p=GetString(); ...
0 votes
2 answers
79 views

Still struggling with vigenere

I have been futzing with this for a couple of weeks. I actually put it away while I did pset3 but, having come back to it, I'm still stuck. I spent an entire day on it this weekend and tried adding a ...
1 vote
1 answer
290 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 ...
0 votes
1 answer
112 views

Pset2: Vigenere Cipher, wrong output

In the following code there is no compiling error, but it does something wrong, as it gives me a wrong output. What it is supposed to do is: when the key is 'a' and the plaintext is 'a', output 'a', ...
0 votes
1 answer
97 views

check50 in pset2

I won't post my code, because, as far as I could tell, it works fine, but I keep on getting this when I run check50 and I don't know know exactly what it means or how to fix it. My code runs perfectly ...
0 votes
1 answer
88 views

cs50 pset2 substitution

hey i think my code is correct, ive compiled it and tested it. check50 is not passing it. the error messages and my code is below. can someone please help? :( encrypts "This is CS50" as &...
0 votes
1 answer
99 views

Vigenere.c: got stucked with this program

I got stucked with Vigenere.c problemset2. With this program the user must prompt a command line keyword that will be used to encrypt a plaintext that the user will later enter. In particular for ...
0 votes
1 answer
16 views

CS50P - One check keep failing in PSET2

def main(): user_input = input("Input: ") print(f"Output: {twttr(user_input)}") def twttr(user_input): vowels = ["a", "e", "i", "o&...
1 vote
1 answer
173 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 ...
0 votes
1 answer
104 views

pset2 How to get rid of spaces in the end of the milo banana_ _ _ _ (input)?

How to get rid of spaces in the end of the input? My code works perfectly with _ _ milla_ _ _ banana But I have issues with the case if _ _ _ milla_ _ banana_ _ _ when I have spaces in the end How ...
1 vote
2 answers
96 views

Initials.c isnt working properly

This is my code #include <cs50.h> #include <stdio.h> #include <ctype.h> int main(){ int i=0; printf(""); char* str = GetString(); printf("%c",*str); while(str[i]!='\...
0 votes
2 answers
17 views

error: conflicting types for 'caesar_crypt'

I declare this function at the start of my C file: #include <ctype.h> #include <cs50.h> #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> ...
0 votes
1 answer
152 views

CS50 pset2 caesar

I am busy with CS50 pset2. I am trying to interpret the error message received: :( encrypts "BaRFoo" as "FeVJss" using 4 as key \ expected output, but not "ciphertext: FeVJss" My programme ...
0 votes
1 answer
377 views

Approach to pset 2?

I'm having problems with pset2 initials. My approach to it is to ask the user for input, and store that input into an array and print the individual initials from there. However, when I use the argv[] ...
0 votes
1 answer
136 views

CS50x - Problem Set 2 - Initials (less)

I've managed to whip up a solution in Python 3 that seems to work. name = input("") initials = name[0] for i in range(0, len(name)): if (name[i].isspace()): initials += name[i + 1] ...
0 votes
1 answer
144 views

PSET2 Initials task

My code has a bug in it which make it output the first initial after the second, would someone please be able to help me and describe what is wrong without having to change my whole code as it all ...
0 votes
1 answer
186 views

My caesar cypher is not cyphering right, can anyone please help?

The code executes but simply prints out the wrong output. For example, when I provide a key of 'a' and then ask for 'aaaa' to be converted, the code prints out 'cccc' instead of 'aaaa'. I can't figure ...
0 votes
1 answer
135 views

Pset2 Caesar won't compile

My code won't compile and I can't tell why. All of the error messages I'm receiving are regarding my "for" statement and my use of the variable i. I also get an error message about my use of "string" ...
0 votes
1 answer
244 views

I've use array pointer method in pset2 (initials.c) but it return "Segmentation Fault (Core Dump) Why?

I'm working on pset2 using array pointer method, but unfortunately, the program return "Segmentation Fault (Core Dump)" I've post a picture of my code below.Can I use this method? or I have to use if ...
0 votes
1 answer
146 views

Pset 2 Initials less comf my code works and passes the test but I would like to know how differenlty could have been implemented

I got initials less comf. pretty quickly thankfully but I would like to know how you guys have implemented the code differently than me. https://gist.github.com/a50582c43587cd3c45d38e9e0c4f956a
0 votes
1 answer
162 views

Pset2 vigenere formula

My formula for vigenere is not quite right, and I'm not sure which part is wrong, could someone leave me some bread crumbs please int j = 0; int upperk = key[j % klen] - 'A'; int lowerk = key[j % ...
0 votes
1 answer
72 views

pset2 vigenere. My code handles text inconsistently

I've got it working nearly perfectly. It works if the text is in lowercase, but I see that it's not working quite right when using uppercase. In check50 it only fails with lowercase: encrypts "BaRFoo"...
0 votes
2 answers
68 views

Can't pass the test on readability

So, I think function 'round' in one case does rounding to the Grade 8, instead of Grade 7. But, if I remove it, another text getting wrong grade. in both cases the grade of either one text is wrong. ...
1 vote
1 answer
122 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 ...
0 votes
1 answer
61 views

no rule to make target pset2

I am currently working on the readability problem in pst2. I followed the 'getting started' instructions to create and open the file in the readability directory, however, I am still getting a "make: *...
0 votes
1 answer
2k views

Pset 2 - Substitution

I hope you are all well. Just had a quick question about CS50 Pset2's substituion problem. Please see my code below. #include <stdio.h> #include <cs50.h> #include <string.h> #...
0 votes
1 answer
31 views

pset2: "vigenere" missing output

when i use isString function or any function which containing "isalpha" function. My code provide missing output. When i remove isString function it works well. But i don't understand ...
0 votes
1 answer
178 views

Week 2 crack compiles, seemingly doesn't do anything

Crack compiles, but when I run it, nothing happens (I know the code isn't pretty, but I couldn't find the fault). It doesn't return anything, doesn't even stop. Thanks in advance! p.s. Sorry for the ...
0 votes
1 answer
162 views

Pset 2 Initials - Function Help

I've written a successful program to complete the Initials section of Pset2 without the use of any functions. However, seeing as I needed to copy/paste a good chunk of code in my program I've decided ...

1
2
3 4 5
26