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
2 answers
16 views

psets2/scrabble.c, In pset2, scrabble im running into an error incompatible comparison between type int and char

How does [POINTS[word[i]] work, I don't seem to get it, somehow I got it to work, but many times it is showing incompatible comparison between type int and char.
WickleTim's user avatar
0 votes
0 answers
8 views

cs50 pset2 crack

i have completed all the previous pset before crack without much trouble. i am not clear on how to link argv[1] with password and not clear either on what loop to use. neested loop or normal loops of ...
Trex Vanga's user avatar
0 votes
1 answer
11 views

Getting " error: declaration shadows a local variable" but i don't know why

int wordsize = atoi(argv[1]); int status[wordsize]; for (int b = 0, wordsize < b; b++) { status[b] = 0; } The error happens specifically at the word "wordsize" in the for loop. I'm ...
Harr's user avatar
  • 35
0 votes
1 answer
13 views

Getting "error: expected identifier or '('" error and I don't know why

char rotate(char c, int n); { int upper[] = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90}; int lower[] = {97, 98, 99, 100, 101, 102, 103, 104,...
Harr's user avatar
  • 35
1 vote
1 answer
249 views

Getting the error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type] and i don't know why

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <math.h> bool only_digits(string s); int main(int argc, string argv[]) { if (...
Harr's user avatar
  • 35
0 votes
2 answers
97 views

Getting "using the result of an assignment as a condition without parentheses" error and i don't know why

for (int i = 0; n = strlen(argv[1]); i < n; i++) { if (isdigit(argv[1][i])) { return 0; } else { printf("Usage: ./caesar key\...
Harr's user avatar
  • 35
0 votes
0 answers
165 views

I was solving the problem set 2 bulbs. I dont seem to understand why the values of both string variables "text" and "s" are changing when I run debug

lines from my code are: #include <cs50.h> #include <stdio.h> #include <string.h> #include <math.h> const int BITS_IN_BYTE = 8; void print_bulb(int bit); int main(void) { ...
Hasan Shahid's user avatar
0 votes
1 answer
17 views

PSET 2 - Substitution - incompatible integer to pointer conversion using strstr function

I am doing PSET 2 - Substitution and am trying to implement a check for every character of the key to be unique. For that I create a helper array key_check, fill it with letters from the key one by ...
zendynar's user avatar
0 votes
0 answers
39 views

PSET2 : bulbs works fine in my terminal but shows bunch error while using check 50

I have coded this problem and executed in my terminal just fine .But when I use check50 to see if there's wrong it tells me that my output is wrong or there's no output even though in terminal its ...
Fayek Ahmed Rahat's user avatar
0 votes
2 answers
23 views

PSet2, Substitution, Unexpected Output - Nested FOR loops producing repeat iterations

I've tried to figure out how an iteration could repeat itself. Iterations 1 and 4 seem to repeat. I've left in my debugging printf lines so you can see how these iterations in my nested FOR loops are ...
fawkeskc's user avatar
1 vote
0 answers
858 views

pset2 - Bulbs - reversing array turns out wrong

I managed to make the right sequence of binary code (in reverse). Next, I do a for loop for reversing it, but it prints out wrong. I have no idea what happens, as the original array is correct, ...
yogmel's user avatar
  • 11
0 votes
2 answers
223 views

pset2 bulbs - getting array out of while loop

I'm working on the pset2 Bulbs problem and I've come to a place where I don't know what to do next. This code takes user text input and converts it to ascii; I can see that the array is being filled ...
mdc690's user avatar
  • 1
0 votes
2 answers
194 views

Error in problem set 2 coke

I completed the task in the problem. When I execute the check50 and I get an error that an output of 50 was not found when the amount entered was 30 but when I check this manually, my code gives an ...
Muhammad Mustafa's user avatar
1 vote
3 answers
2k views

Update to no-vowels: problem returning function result to main(): strange behaviour in CS50 workspace

UPDATE: After posing my original question (please see below), I learned more about variable scope, memory management, etc. I went with the straightforward solution of defining a variable in main(), ...
skytwosea's user avatar
  • 111
0 votes
1 answer
143 views

why does check50 keep telling me this?

I'm doing the "wordle" game from problem set 2 and and I have to verify that the guess has the correct length. It's working perfectly fine when I'm testing it, but check50 keeps telling me ...
spacemonkey's user avatar
1 vote
0 answers
96 views

CS50P Error in pset2 (Coke Machine)

I'm done with my coke machine assignment but now I'm trying to run here in codespace but getting this error, so how am I supposed to fix this? $ python3 coke.py python3: can't open file '/workspaces/...
Ritam Debnath's user avatar
0 votes
1 answer
45 views

substitution - my code passes all tests manually, but not check50

My code for substitution appears externally to be working correctly. It takes the key as an argument and prompts the user for the plaintext message. Both uppercase and lowercase keys work, and a ...
578574's user avatar
  • 1
0 votes
1 answer
17 views

PSET 2 segmentation fault

#include <cs50.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]) { //making sure the program was run ...
Selim Allen's user avatar
0 votes
1 answer
224 views

Lab 2:scrabble compute score function

I'm currently working on scrabble and I'm unsure how to go about making 'word' in line with POINTS[], so they match and have the same values for letters. This is the code I have so far, only recently ...
Robbie's user avatar
  • 5
0 votes
1 answer
29 views

pset2 substitution - handles multiple duplicate characters timeout

One last issue with my Substitution code. I keep getting the following error when I run check50: :( handles multiple duplicate characters in key timed out while waiting for program to exit My solution ...
Joseph J Filoramo's user avatar
0 votes
1 answer
42 views

pset2 substitution, segmentation fault

So my code for pset2 Substitution works about 99% correctly. When I ran check50, I realized that there is still an issue if the user does not type the key right after the program name at the command ...
Joseph J Filoramo's user avatar
0 votes
1 answer
21 views

pset 2 Substitution - extra char(s) in output

So I’ve figured out 99% of the code for the substitution problem. My plaintext input is being output correctly, with the correct enciphered letters and the correct case. However, I keep getting extra ...
Joseph J Filoramo's user avatar
0 votes
1 answer
39 views

why I have additonal output for caesar program?

I have below code written and majority of code is working, but when do check CS50, I have additional output if crypt "a" using k=1 #include <cs50.h> #include <stdio.h> #include &...
Eat个apple's user avatar
0 votes
1 answer
22 views

i cannot see what is wrong but each time i type an input i get the answer in negative numbers aka "before grade 1"

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <math.h> int count_letters(string text); int count_words(string text); int ...
Bushra Mogareb's user avatar
0 votes
0 answers
12 views

Value of variable getting restated just immediately before printing

I'm trying to write a simple program to convert all letters of string to lower case letters. For that I created a function called 'strlower'. Initially I tried to return an array of chars (which ...
DhagashKB's user avatar
0 votes
1 answer
75 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' ...
karlares's user avatar
0 votes
1 answer
31 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 ...
karlares's user avatar
0 votes
1 answer
17 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 = ...
Alexandra Bartee's user avatar
0 votes
1 answer
419 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 &...
yosef's user avatar
  • 5
0 votes
1 answer
72 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 ...
Josh Schaeffer's user avatar
0 votes
1 answer
18 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 ; ...
Amanda Alexandre's user avatar
0 votes
1 answer
68 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 ...
Jaron Haberstroh's user avatar
0 votes
1 answer
102 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&...
kenevarle's user avatar
0 votes
2 answers
72 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> ...
David S's user avatar
  • 103
0 votes
1 answer
37 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= ...
ibrahim's user avatar
0 votes
1 answer
145 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 ...
jiayou's user avatar
  • 17
0 votes
1 answer
285 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 ...
tsull's user avatar
  • 1
0 votes
1 answer
40 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> ...
tsull's user avatar
  • 1
0 votes
1 answer
785 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&...
az ab's user avatar
  • 1
0 votes
1 answer
9 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': /...
Sebastián Vera's user avatar
0 votes
2 answers
228 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 ...
Quach Tu's user avatar
0 votes
1 answer
122 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, ...
krexaim's user avatar
0 votes
1 answer
52 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 <...
Shelby b's user avatar
0 votes
1 answer
145 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 ...
KidAmulet's user avatar
0 votes
1 answer
107 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 ...
getsendy's user avatar
1 vote
1 answer
490 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,...
Flo's user avatar
  • 11
0 votes
2 answers
99 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 ...
Leo8479500282664829200's user avatar
0 votes
1 answer
16 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 &...
Leo8479500282664829200's user avatar
1 vote
0 answers
374 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 ...
Alexander Siewert's user avatar
0 votes
1 answer
53 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 ...
Kuba Oleksa's user avatar

1
2 3 4 5
27