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

CS50 Pset2 Substitution "expected prompt for input, found none"

When I run the code manually, everything works fine: [snipped out code] { if (isalpha(argv[1][i])) { //Check that each character is only ...
user avatar
  • 5
0 votes
1 answer
21 views

Use of bool in PSET2

So i'm trying to approach this pset using functions more than i have in previous attempts. the hints suggested to use bool to check if key is valid. my code compiles and all the rest of the parts ...
user avatar
  • 1
0 votes
1 answer
9 views

Error when calling seconnd function - expected expression

I'm trying to call my encryption function and am getting an undeclared identifier error. Not sure where i'm going wrong. Code: #include <cs50.h> #include <stdio.h> #include <ctype.h> ...
user avatar
  • 1
0 votes
1 answer
21 views

CS50 Readability solution unsolvable to me

I coded this solution myself, but I really can't figure out where I did wrong, I've spent days on this, and I would really appreciate any help!! Please, 😭 #include <cs50.h> #include <stdio.h&...
user avatar
  • 1
0 votes
0 answers
22 views

Ciphertext is not working

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) { //program can only run with one ...
user avatar
0 votes
1 answer
3 views

PSET2 "linker command failed with exit code 1"

So I was working on the Caesars problem trying to check that every character in argv[1] is a digit when i get this error trying to compile it: `/usr/bin/ld: /tmp/caesar-d6b46b.o: in function 'main': /...
user avatar
0 votes
2 answers
14 views

Readability - use of undeclared identifier "i"

I have already identified "i" in my code, but it kept showing me error that use of undeclared identifier "i". I am not really sure how to fix it. Would appreciate if you show me ...
user avatar
0 votes
0 answers
23 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, ...
user avatar
0 votes
1 answer
35 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 <...
user avatar
0 votes
1 answer
15 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 ...
user avatar
0 votes
1 answer
22 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 ...
user avatar
0 votes
1 answer
180 views

CS50P - Error in pset2 (Coke)

In pset2 (Loops), 2nd problem ("Coke"), I believe there's an error in the 4th test that check50 performs: it requires an output of $0.50 after the user entered $0.30. The full price is $0.50,...
user avatar
  • 1
0 votes
2 answers
37 views

check50 says i have no output on pset2 substitution, but my code does output correctly

On my end my code seems to output exactly what check50 wants, yet it says that ive outputted nothing. e.g :( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key Cause ...
user avatar
0 votes
1 answer
14 views

When i try to make this string lowercase, it does it to both the one i want and another one

string key = argv[1]; string low = key; for(int i = 0; i < strlen(low); i++) { low[i] = tolower(low[i]); } through the debugger i can see that this is correctly making &...
user avatar
0 votes
0 answers
100 views

How do you call a boolean function in main?

In problem set two it asks to use a separate function outside of main to determine if the string argv[1] has digits. I believe I've done this correctly in that function, but I'm struggling to call it ...
user avatar
0 votes
1 answer
37 views

PSET2 -CAESAR - compiler doesn't see the rest of program

i have a problem with this pset. My program compiles properly, but when i'm launching it with key, it stops before get_string... When i'm using the only_digits function which is commented in bottom of ...
user avatar
0 votes
0 answers
48 views

pset 2, SUBSTITUTION, working according to specs EXCEPT for UPPER LOWER case spec, code review request

Could anyone please review my code? Specifically the last lines, concerning the case assignment. I got all the other specs to work, except for that last part. I can't figure out what is it that I've ...
user avatar
0 votes
1 answer
32 views

encrypts "a" as "b" using 1 as key output not valid ASCII text

I have been trying to figure out what the issue is in my Caesar code. When I run check50, I see 2 errors - encrypts "a" as "b" using 1 as key output not valid ASCII text & ...
user avatar
0 votes
0 answers
30 views

PSET2 SUBSTITUTION works fine ONLY if plaintext is UNDER 9 CHAR

I was approaching the end of the substitution problem of PSET2 when I hit a snag I could not solve. I have already written the code to check the key for the various conditions they provide. My problem ...
user avatar
1 vote
1 answer
25 views

pset2, problem SUBSTITUTION, Is there more than 1 way to check for repeated characters in the 26-character key?

I have a question concerning pset2, SUBSTITUTION. I finalized the 3 initial filters of this problem: character count argument count non-alphabetical characters. now I'm moving to the fourth ...
user avatar
0 votes
1 answer
22 views

How to solve "error: expected expression" while doing Caesar.c

I'm trying to solve Caesar but i keep getting this error: caesar.c:37:20: error: expected expression s[i] = char(int(text[i]+k-97)%26+97); \\ the arrow points to the 'c' in char #include <ctype.h&...
user avatar
0 votes
1 answer
80 views

Question CS50 2021 Caesar - where is the bug?

I'm currently struggling with a bug in caesar pset2. If i use check 50 everything is green except: :( encrypts "a" as "b" using 1 as key output not valid ASCII text :( ...
user avatar
0 votes
2 answers
43 views

Caesar project: error: redefinition of 'i'

#include<stdio.h> #include<cs50.h> #include<string.h> int main(void) { string name = get_string("Enter: "); printf("%s\n",name); int n = strlen(name); printf(&...
user avatar
0 votes
1 answer
22 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 &...
user avatar
  • 1
0 votes
1 answer
39 views

Pset 2 - Validating the Key

I'm very new to all this and so am struggling a bit with the for loop. Here is my code: #include <stdio.h> #include <stdlib.h> #include <cs50.h> #include <string.h> #include &...
user avatar
0 votes
1 answer
20 views

substitution question segmentation fault issue

I am doing the substitution question and I keep running into this segmentation fault issue but i do not understand what exactly is causing the memory access issue. once j=4, the memory fails to be ...
user avatar
0 votes
1 answer
22 views

Pset 2 ceaser problem

it,s compiling but it is not checking the words are digits or alphabets neither it is printing I included all the header files I don,t know what is going on.
user avatar
0 votes
0 answers
30 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 ...
user avatar
1 vote
2 answers
54 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 ...
user avatar
0 votes
0 answers
27 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 ...
user avatar
0 votes
1 answer
34 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 (...
user avatar
0 votes
1 answer
52 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 ...
user avatar
  • 3
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 ...
user avatar
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)...
user avatar
0 votes
1 answer
35 views

PSET2 Substitution: Trouble only in encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key

so this is my code. All problems are compiled successfully except this one. The output is "Segmentation fault" this is my code: #include <stdio.h> #include <cs50.h> #include <...
user avatar
0 votes
1 answer
30 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/...
user avatar
0 votes
0 answers
30 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 ...
user avatar
  • 1
0 votes
1 answer
22 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 ...
user avatar
1 vote
1 answer
676 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 ...
user avatar
0 votes
1 answer
838 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("%...
user avatar
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 ...
user avatar
  • 14
0 votes
1 answer
28 views

CS50 Pset2 Readability Second Argument Not Compiling

#include<stdio.h> #include<math.h> #include<cs50.h> #include<ctype.h> //prototype for a custome function int letters, words, sentences(string text); int main(void) { // ...
user avatar
0 votes
1 answer
42 views

Pset 2, readability: is everything a float and rounding problems

I' at the very end of readability and am having trouble getting the math correct and rounding it. I'm getting the correct letters, words and sentences, but am getting wildly wrong values for the grade ...
user avatar
0 votes
1 answer
162 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 ...
user avatar
0 votes
1 answer
69 views

Caesar works as intended but check50 says it doesn't

I've tested all the possibilities where check50 says my code isn't working as intended and I always get the expected result. I can't seem to figure out what I did wrong. Here's check50: :) caesar.c ...
user avatar
  • 1
0 votes
1 answer
45 views

Hello everyone, i have a problem with my code for caesar

So when i run the following code in the caesar.c that is located in the caesar folder, it seems to run only for the very first character of the given plaintext and then the next characters are missing....
user avatar
  • 1
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] = ...
user avatar
0 votes
1 answer
47 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[]) { // ...
user avatar
0 votes
1 answer
85 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> #...
user avatar
  • 37
0 votes
1 answer
149 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(&...
user avatar

1
2 3 4 5
26