Questions tagged [pset2]

The problem set for Week 2 continues with the C programming language used in problem set 1.

229 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
1answer
348 views

command line arguments help to use them in the program

I'm not sure how to include the input from the command-line arguement. I try to set the arguments equal to variables, bu it's not working. #include <stdio.h> #include <cs50.h> int main(...
0
votes
1answer
46 views

Caesar doesn't change plaintext?

Program copiles and runs but doesn't change anything to plaintext. #include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> int main (int argc, string ...
0
votes
1answer
52 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
1answer
335 views

My crack code works for rofl but not for all

My crack code works for the rofl code but not for all I tried two other codes and I don't know why was it not able to crack thos codes even when I increased my range of characters for search #define ...
0
votes
1answer
45 views

Operations with Strings and Integers

I do not get it with the correct conversion string-int in the exercises Initials and Caesar. It tried it with all different solutions and functions, but nothing worked;( Could someone help me please? ...
0
votes
1answer
118 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
1answer
355 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 ...
0
votes
1answer
42 views

problem with displaying encrypted characters

can someone please have a look at my code(portion where im trying to encrypt the pain text in the for loop) and let me know where im going wrong. my program does not display . here is a portion of my ...
0
votes
1answer
46 views

pset2 caesar, I really dont know, its printing the first capital twice?

im stuck now, I cant see it. Its all working and ciphers correctly, but whenever the first index of plaintext is a capital, it seems to print it twice? I have gone through it line by line for ages ...
0
votes
1answer
111 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
0answers
38 views

What is wrong with my code?

In this program I am trying to receive an input as a string using argv[] and then I am trying store corresponding values of argv[1][i] into an array var[i] using switch case and I am finally adding up ...
0
votes
1answer
238 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
1answer
47 views

Vigenere problem output

Hi I hope somebody can help! my program works fine but only when it gets to the end of the keyword it passes one character and doesn't print. #include <stdio.h> #include <cs50.h> #include ...
0
votes
0answers
88 views

Vigenere strange problem with isalpha (solved it but still interesting)

Don't get the problem why some letters from my keyword are not interpreted as letters (alpha). Here my code. To try to debug it instead of printing the encrypted phrase i print the table (see below ...
0
votes
1answer
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
2answers
316 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
1answer
140 views

pset2(Alternative Solution opinion

I know theirs a billion ways to implement a solution , heres what i came up with and it passed all the tests. What do you guys think int main(void) { string name = get_string(); void ...
0
votes
1answer
43 views

vigenere output

Ok. I've been working on this for two days now and have checked various types of answers on here, but I'm not sure what's wrong with my code. I think maybe I need a fresh pair of eyes, or my equation ...
0
votes
0answers
100 views

Vigenere - is there a simpler logic behind it?

My code for vigenere.c works for check50, but ends up being much longer than caesar.c in the encipher part.I was wondering if I was missing a simple point and have meandered through the logic behind ...
0
votes
2answers
138 views

check50 pset2 cs50 2017

I ran the check50 command on the terminal window for my program caesar pset2 but I am unable to understand the error message in red as follows : :) caesar.c exists :) caesar.c compiles :( encrypts "a"...
0
votes
1answer
51 views

Segmentation fault in initials.c pset2 cs50 2017

The following is my code for pset2 initials 2017 and I got a segmentation error. Can someone plse help me debug this. Now here's the output : Hello what's your name? ansh parashar ...
0
votes
0answers
371 views

Crack.c in PSet2 - is strcmp() necessary? & other questions

So I've been stuck on crack.c for two weeks now (not literally - I have a full time job too ha) and on top of having 50 questions about it, I just can't get my head round the solution! Basically I ...
0
votes
2answers
908 views

Segmentation fault: cannot replace character in string

string increment(string s, int loc) { char c = s[loc]; c += 1; s[loc] = c; return s; } increment("A", 0); returns Segmentation fault at s[loc]=c;and I have no idea why. Is there a specific ...
0
votes
1answer
130 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
1answer
177 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
1answer
24 views

initials not accepted by auto check

I just can't figure out why check50 does not accept it #include <stdio.h> #include <cs50.h> void isUpperCase(char ch){ if (ch >= 'A' && ch <= 'Z') printf("%c\n", ch); ...
0
votes
1answer
82 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
1answer
214 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
1answer
67 views

PSET2 Initials.c initials not being printed out at all

My code just stops after I get the string from the user, and I'm not sure why it isn't continuing. Any pointers? int main (void) { printf("What is your full name?\n"); string s = get_string()...
0
votes
1answer
145 views

Problem with Pset2

Please help me with this program i have compile it hundred times and run check50 and submit50 command but it keeps on saying this and also submission cancel do you mean to submit something please ...
0
votes
1answer
145 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
1answer
146 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
1answer
149 views

Segmentation fault using get_string()

Working on pset2: "initials.c" ... my code runs fine, outputting the expected initials when it opens with a statement such as string s = " John J Smith"; (which I used during programming to avoid ...
0
votes
1answer
100 views

am on pset2(morecomfortable), the code gives me the desired result but it doesnt pass the check

#include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main(void) { string name = GetString(); for (int i = 0, n = strlen(name); i < n; i++)...
0
votes
2answers
786 views

PSET 2 Crack.c Hackers edition

I'm stuck on pset2's Hacker Edition crack.c. I made this code after exploring various ideas for hours and it really makes sense to me but apparently the dumb computer can't really understand what I'm ...
0
votes
0answers
129 views

String is printed twice in nested for loop

Help, I think I'm going nuts. For crack program, I made a nested loop that iterates through my dictionary words array (I realize that's not strictly necessary for the assignment, but I added it anyway ...
0
votes
1answer
95 views

I have some problems with vigenere

My English is not quite good, and it's difficult to understand videos and lectures cs50. I have some problems with vigenere. Maybe I do something wrong, help me please. #include <stdio.h> #...
0
votes
1answer
94 views

Caesar pset2:Should I convert every letter of plaintext to uppercase after user input?

What if the user inputs both upper and lower case in the command line .should I convert them to upper case and print in upper case ? In the Caesar pset 2
0
votes
1answer
75 views

Pset 2 Vigenere, new to coding and cant find the problem

I am very new to coding and cant tell where the problem with this is. It does compile however when run it returns the string exactly as it was input, including non alphabetic characters. I'm unsure of ...
0
votes
1answer
30 views

pset2 initials first initial repeats

My code is almost working. A bug occurs when you type more then 2 names, e.g. when you type James Henry George, it will give JH JG The problem is in this part of my code: //select first letter of ...
0
votes
1answer
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 ...
0
votes
0answers
82 views

pset2 the last stretch

#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(int argc, string argv[]) { if(argc != 2) // RETURNS TO 1 if ...
0
votes
1answer
160 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
1answer
149 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
0answers
42 views

Why does check50 say the ouptut is C:?

This is my code so far. When I run check50 on this program, the errors are mostly, for example, "input of 100.00 yields output of 212.0 \ expected output, but not "C: "" also, it says that my program ...
0
votes
1answer
49 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
2answers
254 views

Pset2. Caesar. Can anybody help me please? What I am doing wrong?

Here is my code for caesar: #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]) { if (argc!=2) { ...
0
votes
1answer
979 views

expected '(' after 'if' error

#include <cs50.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> int main (int argc, string argv[]) { if (xxx) { do this; ...
0
votes
2answers
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
1answer
97 views

My solution outputs the correct values but it gives me onesebb/n on the last output

#include<stdio.h> #include<cs50.h> #include<string.h> #include<ctype.h> #include<stdlib.h> int main(int argc, string argv[]) { int k =0; if (argc != 2) { printf("...