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
27 views

How do I assign a variable to all possible values of another variable?

I hope my question was worded right but I'm trying to solved pset2 caesar and i don't understand how to print something only if all the possible values of a variable fit the condition. If I input &...
0 votes
3 answers
22k views

How to Wrap Around Array Indexes?

I have the Vigenere encryption portion working properly, but can't seem to figure out how to wrap around argv[1] indexes. My first for loop declared two ints, i and j, and incremented each int with ...
0 votes
1 answer
33 views

I've been trying to submit ceaser and it won't compile can someone help?

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
0 votes
0 answers
34 views

pset2 readability critique - how does my code look?

after struggling for days on end with scrabble, I decided to really spend my time consuming all the information possible from notes/lectures/shorts etc. Just finished readability only taking a few ...
1 vote
2 answers
63 views

cs50 readability problem set 2

I was wondering if someone could help me out with my code for the readability problem set. I have another solution but I was trying to make each process for counting letters, words and sentences ...
0 votes
0 answers
29 views

One last error in pset2 Caesar regarding key 65 (barfoo) - lost for how to fix!

I have read just about every question and answer to exist on the internet about this problem, rewatched lecture segments and walkthroughs, and done additional research on the functions used to try and ...
0 votes
1 answer
36 views

Why is it asking me to declare (s) when is has been declared already?

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> bool is_valid_key(string s); int main(int argc, string argv[]) { if (...
0 votes
1 answer
53 views

Question on pset2 caesar - segmentation

I am really stuck on pset2 Caesar. I can compile it, but when I try to enter valid command line argument, it keeps on saying that I have a Segmentation fault. That seems to mean that I access memory ...
0 votes
2 answers
44 views

Caeser Pset2: Segmentation Fault

#include <stdio.h> #include <math.h> #include <string.h> #include <ctype.h> #include <cs50.h> #include <stdlib.h> int main(int argc, char **argv) { if ((int)...
0 votes
0 answers
32 views

Readability Pset2 - check50 multiple test fail

This is the code for readability problem set 2. The code is working but not properly as it's failing test cases. the output grade is either +-1 from the expected result. Is there something wrong while ...
0 votes
1 answer
33 views

Pset 2 (Substitution), time out (handling of incorrect chars)

The below code lost a mark; check50 gave the explanation just below. A different time-out query (by Abhijit) appears to have had a different cause. The check50 line used: check50 cs50/problems/2021/x/...
2 votes
1 answer
299 views

pset2 crack password does't work

I'm trying to make pset2 crack but having so much problems and my head is about to explode. Here is my code; my first error is on line 41. I never get to pass a value to the key for crypt. I'm very ...
0 votes
0 answers
35 views

error: address of stack memory associated with local variable

I have the following function: string encipher( string plaintext, string key) { int size = strlen(plaintext); char ciphertext[size]; // For each alphabetic charaters determine what letter ...
0 votes
1 answer
23 views

Pset 2 Substitution Segmentation Fault

I'm currently running into a segmentation fault when I don't put a key in the command line. I'm trying to say that if argc = 1 then "Please type key in command-line." but instead I'm getting ...
1 vote
1 answer
921 views

CS50 pset2 substitution - timed out while waiting for program to exit

I tried all the provided examples on the pset2 site, and I got all of them correct. But when I used check50 to check my code, it said: "timed out while waiting for program to exit" for some ...
0 votes
1 answer
983 views

Error: format specifies type 'char' but the argument has type 'string'

This is the code written: #include <stdio.h> #include <cs50.h> int main(void) { string name = get_string ("what is your name\n"); scanf("%s", &name); printf("%...
-1 votes
1 answer
583 views

Crack -- why does my code only work on the 4 character passwords?

I've gotten a semi-workable solution on the Crack problem but there's something I'm not understanding about the strcmp function. My goal was to incrementally build an array through all possible ...
0 votes
1 answer
24 views

Why does my code count a '.' only at the end of a multi-word string, but not at the end of a single word string?

I don't want my code to count non-alphabetic characters. It doesn't if they are alone, or at the end of a single word string. Why does it count an extra character at the end of a multi-word string or ...
0 votes
1 answer
176 views

pset1 problem set 2 readability

I completed the code for pset1 problem set 2 readability as follows #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <math.h> int ...
0 votes
2 answers
35 views

Char repetition in key

I 'm trying to avoid char repetition in key // making chars array of alphabets string alph = "abcdefghijklmnopqrstuvwxyz"; //making sure that there is no character repitition char rep[26] = ...
0 votes
1 answer
50 views

Implementation problem

#include <stdio.h> #include <ctype.h> #include <cs50.h> #include <string.h> #include <math.h> #include <stdlib.h> int main(int count, string input[]) { // ...
0 votes
1 answer
3k 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
1 answer
96 views

caesar pset2 "expected expression and use of undeclared identifier" error

When compiling this code getting mutltiple errors any idee why is the couse of these errors thanks. #include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #...
0 votes
1 answer
185 views

incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int'

I keep getting this error when I try to compile my program: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' { if (argc != 2) { printf(&...
0 votes
2 answers
68 views

stuck on readability pset2

Hi I am stuck on readability and am not sure what i am doing wrong $ ./readability Text: one fish. two fish. red fish. blue fish 8 3 42 13 Grade 13 and my code: #include <stdio.h> #include <...
0 votes
1 answer
42 views

Pset2 - Readability doesn t compile

#include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> int main (void) { string text = get_string("Text: "); float num_letters,...
0 votes
1 answer
2k views

Get help in Pset2 Substitution

The Errors- :) substitution.c exists :) substitution.c compiles :( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key output not valid ASCII text :...
0 votes
2 answers
399 views

Caesar Error:Invalid operands to binary expression ('string' (aka 'char *') and 'int') int c = ((int)text + argv[1]) % 26

There are a few errors in my code, but the one I really don't understand is `caesar.c:25:42: error: invalid operands to binary expression ('string' (aka 'char *') and 'int') int c = ((int)...
0 votes
1 answer
144 views

Pset 2 Readability

What's going wrong? I think I've got it figured out but I'm unable to compile the program and print out what I want it to say.
0 votes
1 answer
29 views

toupper not executing

I am working my way through approaching the scrabble problem from PSET2. Right now I just want to focus on getting all my string inputs transferred over to uppercase and then having their values ...
0 votes
2 answers
64 views

Readability Wrong Output at Index around 7-8

I have been struggling with Week 2 Problem Set 2 Readability Question. At this point, I feel like I am stuck, and spend too much time just trying to fix one error. The code works perfectly except &...
0 votes
3 answers
454 views

How to reject repeated letters for Substitution in Problem Set 2

I am trying to write some code for the Substitution question in Problem Set 2, but I cannot figure out how to reject the case where a user gives a key with repeated letters. My code thus far is as ...
0 votes
1 answer
39 views

Program won't print out enciphered text

So under "Peeking under the hood" they asked to ignore the key the user provided and instead prompt the user for a plaintext and move each character by 1. when I run my program, and input &...
0 votes
1 answer
66 views

How do I check that every character of an array is a digit and only print out the string if all the chars are digits?

So, in Caesar when validating the key they asked to check if all the characters in the command line argument provided are digits and only printout "Success" and the digits as an integer if ...
0 votes
1 answer
887 views

variable used in loop condition not modified in loop body

i'm having some trouble here, not even sure if my loop is correct but i'm also confused as to why I got this error about the why the cents variable can not be modified, if anyone can explain to me ...
0 votes
1 answer
40 views

Error in Caesar of Pset2 while validating entered key

My question is regarding the step of 'Validating the Key' in Caesar of Pset2 , while checking whether the key given by user consists of digits. Here is my code : #include <stdio.h> #include <...
0 votes
1 answer
18 views

Logical error in Caesar of Pset 2

The logical error is occurring when i try to shift each character of the plaintext by 1 string plaintext= get_string("plaintext: "); //aplplying key for(int j=0,m=strlen(plaintext);...
0 votes
1 answer
57 views

pset2- readability

While counting the number of sentences ( Pset 2: Readability) , how do we differentiate between exclamation marks within a sentence and those which are used to end a sentence ? This is my code: //...
5 votes
4 answers
7k views

How to handle the lack of argv[1] in caesar?

I think my program handles lack of argv[1] correctly, yet it fails check50's test. here my code: if ( argc != 2 ) printf ("usage : ./caesar + key \n"); return 1;
0 votes
1 answer
23 views

I have included all the libraries, yet it shows errors (pset2)

This is my code: #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main (int argc, string ...
0 votes
1 answer
63 views

cs50 pset2: check50 does not accept output

I am running check50 but it will not accept my output as correct. For example, one of the conditions needed to be satisfied is: When I run the code below I obtain the desired output (CAQGON) but ...
0 votes
1 answer
50 views

Help with Either Command Line Argument or Arrays for Problem set 2 Caesar

I am on Problem Set 2: Caesar. Right now I'm trying to write code that first checks if the second command line argument is a int and if it does prints the integer. I got my program to compile after ...
0 votes
1 answer
43 views

float rounds with %2.f

I'm working on pset2 with cash. But something interesting is happening if input is 6.876 and i printf that value of that variable I get 6.88 instead of 6.87. How can I get 6.87 instead of round 6.88? ...
0 votes
2 answers
45 views

What modification do I need to shorten my code?

I have come up with the following code to solve caesar.c of pset2. It passes all check50 tests. However, it fails to detect when a string input is not a number. The way I understand it, I have to ...
0 votes
2 answers
267 views

Caesar : Extra random characters at the end of a char ciphertext array

I'm having a problem with an output. Sometimes output adds an extra characters, different each time the code runs. For example, when I use key "1" and write "a", it displays "...
0 votes
1 answer
33 views

Having Trouble using StrCpy with Command Line argument for Problem Set 2 Caesar. Trouble with Array

Hello I'm still fairly raw at this coding thing so i'm sure im making rookie mistakes. I'm doing Problem Set 2 caesar and I've hit a wall and haven't been able to move forward. What I have been trying ...
0 votes
1 answer
25 views

Undeclared identifier error inCS50 Pset2 caeser

I keep getting 2 undeclared identifier errors on these respective lines line 48: printf("ciphertext:%c", ((p[n] - 65 + k) % 26) + 65); line 54: printf("ciphertext:%c", ((p[n] - 65 +...
0 votes
1 answer
35 views

pset 3 caesar - output looks fine but check50 returns errors

PS2 caesar to output ciphertext works fine, and outputs all texts as expected - however check50 returns poor score. //Code is: #include <stdio.h> #include <cs50.h> #include <string.h>...
1 vote
2 answers
44 views

CS50 Readability compile error

Im trying to compile the program but keep getting this error message below: Can someone tell me what this means please. The carat arrow is supposed to be pointing at "char" and "ch&...
0 votes
1 answer
51 views

CS50 readability.c:31:1: error: expected identifier or '(' {

I keep getting this same error message readability.c:31:1: error: expected identifier or '(' { Please Help! I put my program below: #include <stdio.h> #include <cs50.h> #include <math.h&...

1
3 4
5
6 7
26