Questions tagged [pset2]
The problem set for Week 2 continues with the C programming language used in problem set 1.
1,266
questions
0
votes
1
answer
72
views
pset2 vigenere, wont find key in position j the second time around
i really didn't want to ask on here but i cant see the problem for this really strange result. im not 100% finished with this code, i was just checking my algorithm was working before completing it. i ...
0
votes
1
answer
7
views
readability error
I keep getting this error: 'declaration shadows a variable in the global scope'
how do I fix it ?
here is my code
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <...
0
votes
1
answer
58
views
My pset2 caesar program keeps giving an output of 0, how to get to the ciphertext?
I came up with these lines of code to get from a character in the plaintext to a new character in the ciphertext. I keep getting an ouput of 0 everytime I run it, no matter which key I choose or which ...
0
votes
1
answer
67
views
Vigenere Pset2 ciphertext question + others
(Main question- need help on this for code to work! highlighted in screenshot.)
My PSET2 code works fine up until asking the user to input plaintext, but becomes funky and outputs blank spaces as the ...
0
votes
1
answer
49
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
1
answer
44
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
1
answer
31
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
1
answer
87
views
Vigenere/ PSET 2/ It works for me but it can't pass the check50
Im trying to figure out where my problem is. Usind the examples given with the keys the transcription works fine. But if i try to run check50:
//Checking for right argument
if (argc != 2)
{
...
0
votes
1
answer
46
views
PSET 2 IDE Compiling Issues
I am now on PSET 2 and moved to the CS50 IDE, however, when trying to set up and test the IDE by writing and compiling a simple piece of code under the title readability, i get the below error. I ...
0
votes
1
answer
32
views
Comparing the hashed version of different string to the provided hash.
I am badly struck at the Crack problem in pset2.
I have an idea which uses 5 for loops, to check for all the possible variations of the alphabets. Considering a case where the password is only of ...
0
votes
1
answer
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
2
answers
42
views
PSet2 / Substitution
I am trying to make an upper case key and a lower case key of the one typed by the user but when I use the toupper and tolower functions they turn all my chars into lower or upper. Not just the one I ...
0
votes
2
answers
273
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
1
answer
8
views
Pset 2 - Substitution: Incompatible Integer to Pointer Conversion Error
I've tried this over and over and can't get this right. This is only a snippet of my code. I keep on getting this error:
"testcode.c:21:31: error: incompatible integer to pointer conversion ...
0
votes
1
answer
48
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
1
answer
53
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
1
answer
483
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
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
1
answer
59
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
89
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
452
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
216
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
377
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
158
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
110
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
243
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
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
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
84
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
78
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
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
1
answer
86
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
14
views
Help with cipher text in Pset2 substitution
I think I am getting close on Pset2 substitution. But every time I run this code it outputs my ciphertext as void. There's obviously something wrong with my loops converting plaintext to ciphertext ...
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 ...
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
1
answer
149
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
376
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
134
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
134
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" ...