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

pset2 - caesar : output is providing extra symbols after specific input cases

If someone has the time to explain to me how I can fix my code that would be greatly appreciated! Thanks :) Problems that I need help with: 1 - Program needs to accept single character inputs like 'a' ...
0 votes
1 answer
11 views

pset2 readability test not calculating correct grade

I believe I've written the readability.c program correctly to count letters, words, and sentences based on readability prompt and calculate the grade index. But whenever I test the grade index, I'm ...
0 votes
0 answers
15 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' ...
  • 1
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
67 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 &...
  • 5
0 votes
1 answer
37 views

Segmentation error on isdigit function

Been looking for answers to this, but having a lot of trouble. I am receiving a segfault that seems to be coming from the isdigit line, though I'm not sure what is happening to argv[1] to cause the ...
0 votes
1 answer
13 views

Can't print/populate a string in C

In PSET2 Substitution, to display the results, I'm initializing an empty string with: char cyphertext[] = {'\0'}; Populating it with: // makes the substitution for (int i = 0; text[i] != 0 ; ...
0 votes
1 answer
27 views

PSET 2 Readability: undefined reference to `count_letters'

I'm receiving the error: /usr/bin/ld: /tmp/readability-1786f7.o: in function main': /workspaces/109105972/readability/readability.c:19: undefined reference to count_letters' clang: error: linker ...
0 votes
1 answer
15 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&...
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> ...
  • 103
0 votes
1 answer
28 views

p2 substitution i have no idea how to return multiple value from same variable in a function since c doesnt take variable array length

#include <stdio.h> #include <string.h> #include <math.h> #include <ctype.h> int converter(string plaintext,string text ); int main(int argc, string argv[]) { string code= ...
0 votes
1 answer
46 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 ...
  • 17
0 votes
1 answer
76 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 ...
  • 1
0 votes
1 answer
20 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> ...
  • 1
0 votes
1 answer
196 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&...
  • 1
0 votes
0 answers
36 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 ...
0 votes
1 answer
4 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': /...
0 votes
2 answers
47 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 ...
0 votes
1 answer
53 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
42 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
30 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
38 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 ...
1 vote
1 answer
311 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,...
  • 11
0 votes
2 answers
59 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 ...
0 votes
1 answer
15 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 &...
0 votes
0 answers
185 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 ...
0 votes
1 answer
44 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 ...
0 votes
0 answers
50 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 ...
0 votes
1 answer
48 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 & ...
0 votes
0 answers
31 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 ...
1 vote
1 answer
42 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 ...
0 votes
1 answer
50 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&...
0 votes
1 answer
95 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 :( ...
0 votes
2 answers
56 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(&...
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 &...
  • 1
0 votes
1 answer
42 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 &...
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 ...
0 votes
1 answer
25 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.
0 votes
0 answers
38 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
78 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
35 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
54 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 ...
  • 3
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
1 answer
44 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 <...
0 votes
1 answer
35 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/...
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
1k 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
1k 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("%...
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 ...
  • 14

1
2 3 4 5
26