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
5
votes
4answers
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
1answer
20 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
59 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
1answer
40 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
21 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
36 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
96 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
16 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
29 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
40 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
34 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
22 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
1answer
2k views

about caesar,i'm having a segmentation fault

#include<stdio.h> #include<cs50.h> #include<string.h> #include<stdlib.h> #include<ctype.h> int main(int argc,string argv[]) { printf("%s",argv[1]); string k=argv[1]; ...
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
37 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
25 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
26 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
44 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
49 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
49 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
1answer
162 views

PSET2 Readability, most of my code works as expected, but one passage provided below

include include include include include int main(void) { // Ask user for input string s = get_string("Text:"); // variable to store letter, word, and sentence count int letterCount ...
0
votes
2answers
2k views

Problem Set 2 - Caesar Check

My code compiles and it seems to handle the encryption of the given text correctly...but not according to the cs50 check. Here's the result of the check: :) caesar.c exists :) caesar.c compiles :) ...
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 ...
-1
votes
1answer
27 views

Can't get PSET2 Caesar to compile

I'm having trouble getting my version of Caesar to compile. It keeps saying: error: use of undeclared identifier 'n' for (int i = 0; n = strlen(unencrypted); i < n; i++) I thought maybe I was ...
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 &...
1
vote
1answer
33 views

Any advice on getting the CS50 IDE to read my closing parentheses, brackets and curly brackets

I've been trying to work on the Caesar problem in CS50 and keep running into the same problem of it not reading the second parentheses of my printf code. When I try to test it without the printf ...
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; ...
0
votes
1answer
40 views

cs50 pset2 substitution Segmentation error

I am stuck at working out what is wrong with my code. I receive the values entered at the command line, I ask the user for text, I validate the command line values as characters of the alphabet and ...
0
votes
1answer
21 views

PSET2 - Why do I get the errors in the check50?

My code: #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> bool validate (string key); int main(int argc, ...
0
votes
1answer
18 views

PSET2 substitute

Why do I only get the corresponding key for A and B and not c and d with my code? #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main(void) { ...
0
votes
1answer
35 views

readability - resulting grade is incorrect

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <math.h> int main(void) { string text = get_string("Text: "); ...
1
vote
2answers
84 views

I truly confused on why ceaser won't work,

#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
1answer
36 views

Getting a "seg fault" on Caesar, Pset2

This is my code for Ceasar (pset2) of cs50. Whenever I try to make the program, I get a control may reach end of non-void function Could you help me with this? #include <stdio.h> #include <...
0
votes
1answer
59 views

Caesar prints out the desired output but fails the check50

I managed to write the code for caesar and it presents the desired values as output. However, when I execute check50, apart from a smiley on all other points, this is what I get: :( handles non-...
0
votes
1answer
24 views

Pset2 Substitution My code working when I use debugger and does not working thorough console or test. What am I doing wrong?

Sorry for my English( I am learning. 1.I have make this code, but when I have wrote "isduplicate" function it makes uncatchable bug. Code work as my expectetion only in debugger. So where is ...
0
votes
1answer
28 views

Pset 2 - Readability -> Wrong grade

I'm having problems with the Pset 2 problem: readability. The goal of exercise is to implement a program that computes the approximate grade level needed to comprehend some text using the Coleman-Liau ...
0
votes
1answer
35 views

Substitution Just can't handle invalid keys

My code - #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> bool check_distinct_char(string s); bool check_char(string s); ...
0
votes
1answer
27 views

pset2 substitution unable to identify string which has character repetition

Here is my code- #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> bool check_distinct_char(string s); bool check_char(...
0
votes
1answer
22 views

pset2 substitution checking if all the characters in the key are different

I have almost finished substitution. Just that I have not yet been able to come up with a elegant way to check if all the characters in the key are distinct hence I used the following way to check if ...
0
votes
1answer
41 views

caesar pset 2 non-numeric key error even when it works well when i try it myself

Here is my code which works well even with non-numeric key. #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> bool key_check(...
0
votes
1answer
25 views

Caesar Code Complies when I think it shouldn't

One of the lines of my code is this - if (isupper(plaintext[j])) { int cap_end = (plaintext[j] - (int) 'A' + atoi(argv[1]))%26 + (int) 'A'; printf("%c", (char) cap_end)...
0
votes
1answer
45 views

Errors in Caesar pset2 and Wrong Output

I am almost finished with Caesar only a couple of issues persist which I am unable to overcome Here is my code - #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <...
1
vote
2answers
95 views

pset2 - readability - grades slightly off

I have a problem that I have not been able to diagnose on my own or by perusing this stack overflow. The the tests are here. All of the index values are correct except for the grade seven sentence ...
0
votes
1answer
56 views

Trying to implement itoa function in pset2 caesar

While working on Caesar i realized i needed a function to convert an int to a string and searched online. The first one I came across was the itoa function but it turned out it wasn't a standard ...
0
votes
2answers
70 views

Caesar pset2 How to Reprompt user for Command Line Argument?

I have started working on Caesar and I am stuck with how to repromt user for a command line argument incase they input some wrong values. Here is the code i wrote and I can't find any apparent errors #...
0
votes
1answer
28 views

Segmentation Error while Using if Statement for Pset2 Caesar

I have been working on Caesar for some time now and tried to use different loops but I am getting Segmentation Errors. #include <stdio.h> #include <cs50.h> #include <stdlib.h> #...
3
votes
4answers
2k views

Pset2 Readabilty: Why are my grade levels calculating incorrectly?

For Pset2: Readability, I'm writing a program in C that prompts the user for text input, analyzes how many letters, words, and sentences are in the text entered by the user, and calculates the grade ...

1
3 4
5
6 7
25