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

I'm on pset2 vigenere.c. need help with encryption

I've been struggling with vigenere for months. please help me to figure out my errors and guide me clearly. any help much appreciated. #include <stdio.h> #include <cs50.h> #include <...
0
votes
1answer
106 views

Vigenere acting odd

I have spent hours trying to figure out why my vigenere check50 does not completely work and I was wondering if anyone here could help me. string k = argv[1]; //iterates through the ...
0
votes
2answers
908 views

Segmentation fault: cannot replace character in string

string increment(string s, int loc) { char c = s[loc]; c += 1; s[loc] = c; return s; } increment("A", 0); returns Segmentation fault at s[loc]=c;and I have no idea why. Is there a specific ...
0
votes
1answer
75 views

Pset 2 Vigenere, new to coding and cant find the problem

I am very new to coding and cant tell where the problem with this is. It does compile however when run it returns the string exactly as it was input, including non alphabetic characters. I'm unsure of ...
0
votes
1answer
463 views

Undefined reference to "get_string" (pset2, ceasar)

My code isn't compiling. I'm getting "undefined reference to 'get_string'" I think there is an issue with the way i have contextualized the first part of my code, i.e., above the "for" loop. I'm not ...
0
votes
1answer
188 views

Steps to cipher text

I kind of know what to do... just having a hard time getting my head around it! This is my thinking: once I have asked the user for some text to cipher, I need to check if the text is indeed alphabet, ...
-1
votes
1answer
579 views

Crack -- why does my code only work on the 4 character passwords?

I've gotten a semi-workable solution on the Crack problem but there's something I'm not understanding about the strcmp function. My goal was to incrementally build an array through all possible ...
0
votes
1answer
97 views

correct output except 'a' and 'z' or 'A' and 'Z'

I think i almost did vigenere pset. but output is strange. in 'baz' key: b is correct it increment 1 point but also a increment 1 point and z increment 1 point instead of subtract 1.. İt doesn't make ...
0
votes
2answers
279 views

How do i pass an array into a function?

I have tried passing arrays into functions but I keep getting an error about pointers. So is it possible to pass an array I initialised in my main function to another function I created without using ...
0
votes
1answer
198 views

SEGmentation fault caesar (pset2)

It has been more then a week and I am unable to fix this problem. I double checked everything but I still get this error with capital letters. Can anyone help please? Here is the code I have for this:...
0
votes
1answer
134 views

vigenere.c not printing correctly for some reason

Code: #include <cs50.h> #include <ctype.h> #include <stdio.h> #include <string.h> int main (int argc, char *argv[]) { if ( argc != 2 ) { printf ("ERROR 1\n"); ...
0
votes
2answers
427 views

pset2 vigenere wraparound

I can't figure out how to wrap the k[i] in the formula c[i] = (p[i] + k[i]) % 26 I know the if and else code's are different, that's to illustrate the main implications I've tried. also the printf("%...
0
votes
1answer
197 views

Caesar pset2 - using isdigit(argv[1][i]) only looks at the first character

I have read through the other posts where you need to use argv[1][i] when using isdigit to avoid the error. It does eliminate the error, but it is only reading the first character and stops. I can ...
0
votes
2answers
48 views

Why the if statements don't work when I put them into loops? Caesar PSET2

Help, please. The program works fine until I want to add the loops and when I do that the if statements inside it won't work and it will just ask for the key and will output the same text as the input ...
0
votes
1answer
22 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
27 views

I've been trying to submit ceaser and it won't compile can someone help?

#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
25 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
2answers
65 views

How to invoke command line argument functions outside of main? caesar.c

Let us say I want to create a separate function for lines 11-25 (check comment for reference) in my code as a separate "argument checker" function. Something similar to how I have my decrypt ...
0
votes
3answers
613 views

Pset 2 - String is unitialized, initialize the variable to silence this warning

I am working on Caesar cipher on CS50 Week 2. I have generally wrote most part of the code but the final error message which i have not debugged was the initalizing of the string at the end. How do ...
0
votes
1answer
452 views

Don,t know why it is not printing each char after space

I have written this code to print first char and each subsequent char after "space" to be printed, but it is only printing first char what is the problem. #include <stdio.h> #include <cs50.h&...
0
votes
1answer
26 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
60 views

Having problems producung the correct result using the text extracts provided by CS%). I cant see where it goes wrong when finding the correct grade

CODE: #include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <math.h> int main(void) { // DECLARE LETTER, WORD & SENTENCE COUNT int ...
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
48 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
32 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
1answer
63 views

PSet 2 -- Substitution set:

All the check50 inputs are working fine, apart from the one where the input is "The quick brown fox jumps over the lazy dog". In this case my code works fine till 'jumps' and after that the code doesn'...
0
votes
2answers
45 views

substitution behaves randomly strange

I am working on the main part of the problem. The previous checks all pass ( checking if two arguments, if key is 26 lenght, if key is only alphabetical chars and if every char is only once). But the ...
0
votes
1answer
53 views

why am i getting a non numeric key error? cs50 caesar

i have been trying to do this for a month and i am finaly down to my last error message when i run my check 50.the error message is :( handles non-numeric key timed out while waiting for program to ...
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
22 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
2answers
29 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
42 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
2k views

I keep getting an error: incompatible pointer types passing 'string' (aka 'char *') to parameter of type 'string *' (aka 'char **')

#include <cs50.h> #include <ctype.h> #include <stdio.h> #include <string.h> int shift(string argv[]); int main(int argc, string argv[]) { // Checks to make sure user ...
0
votes
1answer
44 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
36 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
2answers
34 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
35 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
2k views

Get help in Pset2 Substitution

The Errors- :) substitution.c exists :) substitution.c compiles :( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key output not valid ASCII text :...
0
votes
2answers
47 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
1answer
120 views

Pset 2 Readability

What's going wrong? I think I've got it figured out but I'm unable to compile the program and print out what I want it to say.
0
votes
1answer
21 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
2answers
32 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
3answers
333 views

How to reject repeated letters for Substitution in Problem Set 2

I am trying to write some code for the Substitution question in Problem Set 2, but I cannot figure out how to reject the case where a user gives a key with repeated letters. My code thus far is as ...
0
votes
1answer
26 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
44 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
41 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
428 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
1answer
20 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
1answer
18 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
25 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: //...

1 2 3
4
5
25