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
1answer
64 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
1answer
19 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
1answer
21 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) { // ...
0
votes
1answer
18 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 ...
0
votes
1answer
14 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
1answer
24 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 ...
0
votes
1answer
18 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....
0
votes
2answers
28 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
1answer
30 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
1answer
34 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
1answer
24 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
1answer
33 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
1answer
18 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
1answer
21 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
2answers
43 views

Segmentation error on pset2 substitution

I'm trying to work on "substitution" problem set, but I'm getting an error of "Segmentation Fault" when I run the program below: In this part of the program I just want to check if ...
0
votes
1answer
36 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
1answer
205 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
2answers
31 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
1answer
15 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
1answer
17 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
2answers
31 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
1answer
20 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: //...
0
votes
1answer
19 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
1answer
23 views

Can't check CAESAR pset2

I solved the Caesar problem and it works flawlessly. But I can not check it properly. The results are correct but ''' check50 cs50/problems/2021/x/caesar ''' says it is incorrect. If I view the ...
0
votes
1answer
24 views

Check50 problem with Readability

When I submit my readability code check50 says: Expected Output: Before Grade 1 Actual Output: Before Grade 1 Expected Output: Grade 16+ Actual Output: Grade 16+ Since my program outputs what is ...
0
votes
1answer
37 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
1answer
11 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
2answers
35 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
2answers
44 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
2answers
57 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
1answer
25 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
1answer
15 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
1answer
27 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>...
0
votes
2answers
38 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
1answer
30 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&...
0
votes
1answer
20 views

Input Problem in Char 'P' PSET2 Substitution

QUESTION When i put cipheralgorithm (which is a function that is making encryption) in comment section (/*) everything goes perfect i can get input when i type ./substitution ...
0
votes
0answers
29 views

All my functions work individually for Substitution (pset2), but when I put them together the programme doesn't work!

Hey guys :) I've been wracking my brain for ages on my code for pset2 (Substitution) and would really appreciate some help. I've created a function to convert a string into its uppercase variant, ...
0
votes
1answer
35 views

PSET2, Caesar (less)

My code to assess whether the command-line argument consists solely of digits compiles but doesn't work properly, and I can't figure out exactly what the problem is. Even if I enter an integer-only ...
0
votes
1answer
19 views

Segmentation fault: Pset 2 Caeser isdigit

The log is telling me: "Segmentation fault", and after looking into it, I figured out the problem was in the "isdigit", but i don't know how to fix it, i'm here for about 2 hours ...
0
votes
1answer
25 views

Expected output and output are the same, yet the program somehow isn't correct. Caesar

This is my code: for(int i = 0, len = strlen(plaintext); i < len; i++) { char c = plaintext[i]; if (isalpha(c)) { char p = 'A'; if (islower(c)) { p =...
0
votes
1answer
41 views

Why doesn't my Caesar code work?

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> #include <math.h> bool string_validity(string s); int main(int ...
0
votes
1answer
18 views

Caesar scoping. variable len not defined, yet it works

The code is following: #include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <ctype.h> bool key_validity(string s)...
0
votes
1answer
34 views

PSET2 Substitution: Trouble Encrypting all alphabetic characters

First post, so let me know if anything is wrong with the post. My code passes every test except for this one. :( encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key expected &...
0
votes
1answer
37 views

:( handles lack of key failed to execute program due to segmentation fault

The following piece of code I've written for pset2/caesar produces a "segmentation error" when there is a lack of key (when no command-line argument is provided). I don't know which line or ...
0
votes
1answer
45 views

I'm stuck at PSet 2 Caesar Cipher: The alphabets don't follow my modulo 26. It goes beyond it, printing non-alphabetic characters

The crux is at the last part where I've commented "CONVERT PLAINTEXT TO CIPHERTEXT" The variable asciiValue holds the, well, the asciiValue of the enciphered character. As you can see, I've ...
0
votes
0answers
38 views

pset2/caesar handles lack of key failed to execute program due to segmentation fault [duplicate]

#include <cs50.h> #include <math.h> #include <stdio.h> #include <string.h> int key(string input); int main(int argc, string argv[]) { int l = strlen(argv[1]); int ...
0
votes
1answer
21 views

How to print the output in Caesar(Pset2)?

here's my code #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) { // prints Usage : ...
0
votes
2answers
37 views

Readability assignment, getting “Segmentation fault” message

It took me a while to be able to compile and run this program, and now I'm getting a "segmentation fault" message. What have I done wrong? Here's my code: #include <stdio.h> #include &...
0
votes
1answer
27 views

Bad math pset2 - caesar

I tried submitting the solution for pset2 - caesar but I get a lot of errors back. Most of them are to do with wrong translation of the input text. Can anyone tell me where I'm going wrong ? Thank you ...
0
votes
1answer
12 views

I am getting different outputs with my code in CS50 pset1 substitution

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <math.h> #include <string.h> int main(int argc, string argv[]) { int d = 0; int duplicate = 0; ...

1
2 3 4 5
25