Questions tagged [pset2-substitution]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
12 views

Problem set 2 - substitution - key validation issue

My code validates mainly 3 things for the key. Key is composed of alphabets only Key length is 26 Irrespective of case, key contains only one alphabet once But still one of the validation criterion ...
Athi's user avatar
  • 1
0 votes
1 answer
23 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
1 answer
24 views

Characters disappearing in pset 2 substitution

Random characters consistently disapear when I run check50 https://submit.cs50.io/check50/380b6c2b987dbf1d9135d48e03c6b62c481a4f41 I have no idea what could be causing this. This is substitution in ...
AdamBomb210's user avatar
0 votes
2 answers
26 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
0 votes
1 answer
285 views

PSET2 Substitution

#include <cs50.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <stdio.h> int main(int argc, string argv[]) { // Checks if there are two ...
Chi Go's user avatar
  • 3
0 votes
1 answer
441 views

C program getting error: expected identifier or '(' {

As the title says I keep getting the error: expected identifier or '(' {. I cannot figure out where this is occurring. Due to this I don't know if my code will even run or is buggy free. I sort of ...
user avatar
0 votes
1 answer
43 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
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
40 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
178 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
54 views

Trying to reject repeated characters in pset 2 substitution

i can't find out what's wrong with the code i wrote.when i execute ./substitution VCHPRZGJNTLSKFBDQWAXEUYMOI in terminal,it still prompts "Key must not contain repeated characters." #include ...
Hoooly Kuashi's user avatar
0 votes
1 answer
427 views

Segmentation fault (core dumped) after main returns 0

Im getting seg fault after my main functions returns 0, only when I pass lowercase cipher key, Ive run debug50 and the code ran fine, expected output but when it reaches the return statement in the ...
Victor's user avatar
  • 3
0 votes
1 answer
86 views

PSET2 Substitution - Final Check results in "Timed out waiting for program to exit"

I am working on CS50 PSET2 Substitution and have passed all the checks, except the last one: "handles multiple duplicate characters in key." What I get is: :( handles multiple duplicate ...
John H's user avatar
  • 1
0 votes
1 answer
65 views

What are these weird symbols and why am i getting them? (Wk 2 Substitution)

#include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> int main(int argc, string argv[]) { //Error msg if user inputs no or ...
Min Wai's user avatar
  • 11
0 votes
1 answer
183 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
42 views

CS50 pset2 substitution: Segmentation fault in some of "This is CS50" tests

I'm doing Substitution in pset2. My checking result shows that my program has segmentation fault for the last two "This is CS50" tests, as is shown in the pic: Can somebody tell me why, and ...
Astrophel's user avatar
0 votes
1 answer
51 views

pset2: Check50 on Substitution problem fails when output is the exact same

I've been working on the CS50 Substitution problem and I have submitted it. When I submit it, it checks off the standards about compiling and about errors in the key. However, all the other values it ...
Preston So's user avatar
0 votes
0 answers
45 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 ...
Alvaro Barboza's user avatar
1 vote
1 answer
158 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 ...
Alvaro Barboza's user avatar
0 votes
1 answer
28 views

Substitution project and Scrabble lab: Finding analogy

Just started with the Substitution project. It appears there is a close analogy between Substitution project and Scrabble lab. In Scrabble lab, POINTS is an array that contains allotted value to the ...
Splendid Digital Solutions's user avatar
0 votes
1 answer
10 views

pset2 - Any idea why I'm getting a matching index of 2496?

So the substituition pset. On the encipher logic, I'm trying to get the index for the matching ascii's in the plaintext input array and an ordered uppercase alphabet array ([65...90]), but i keep ...
Nonso 's user avatar
0 votes
1 answer
38 views

Can't figure out why check50 sad faced these two

Edit2: Latest code (working) int main (int argc, string argv[]) { // Checking for proper command line input if (argc != 2) { printf("Usage: ./substituion key\n"); ...
Red Ladica's user avatar
0 votes
1 answer
51 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/...
sub2600's user avatar
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 ...
hawki2sl's user avatar
2 votes
2 answers
4k 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 ...
xinyis348's user avatar
1 vote
1 answer
31 views

PSET2 Substitution Segmentation Fault. Works fine with get_string

I was testing some features with editing specific characters in a string, and I made a test script that just says , string test = "a"; test[0]++; printf("%s\n",test); and it ...
Towls's user avatar
  • 11
0 votes
1 answer
119 views

Different results with check50

I'm having different results with check50 with the same code. The code works normally if I type. Sometimes all the results show correct #include <cs50.h> #include <ctype.h> #include <...
Marcelo's user avatar
0 votes
1 answer
35 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 ...
LesBenjamim's user avatar
0 votes
1 answer
93 views

Why am I getting a segmentation fault (pset2 substitution)?

I've written something similar to this code for my answer to pset2 Substitution. The idea is to keep string s the same, but have a variable s_capital that converts s into uppercase. I can't work out ...
James Rosen's user avatar
0 votes
1 answer
125 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 &...
Harry's user avatar
  • 5
0 votes
1 answer
118 views

Pset2 Substitution seems to be correct but is failing some Check50

I have no idea why my code isnt working for the tests below in Check50. :( encrypts "XyZ" as "KeD" using NJQSUYBRXMOPFTHZVAWCGILKED as key :( encrypts all alphabetic characters ...
catshat 's user avatar
0 votes
1 answer
66 views

CS50 PSET3 Substitution replacing some letters incorrectly

Below is my code to solve the substitution problem in pset 2: #include <math.h> #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <stdbool.h> int main(int ...
catshat 's user avatar
0 votes
1 answer
16 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; ...
TechSpy's user avatar
  • 13
0 votes
1 answer
74 views

Getting different outputs when I use debug50 and when I run the program

When I use debug50 on this program I get 26 as the value of 'a' but when I run it I get random large values of 'a'. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
Aakash Malviya's user avatar
0 votes
1 answer
88 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); ...
FoundABetterName's user avatar
0 votes
1 answer
33 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(...
FoundABetterName's user avatar
0 votes
2 answers
40 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 ...
FoundABetterName's user avatar
0 votes
1 answer
40 views

cs50 pset 2 substitution

i am failing to see my fault in logic .... if i run ./substitution qwertyuioplkjhgfdsazxcvbnm and input plaintext: abc instead on ciphertext: qwe i get ciphertext: dvm ...i tried debug50 and it seems ...
andream's user avatar
  • 109
0 votes
1 answer
27 views

Is it just me or PSET2 Correction seems to have a mistake

I ran the check50 on my pset2 Substition.c I get everything right except for 1 encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZteogxhcipjsqd as key expected "...
007's user avatar
  • 3
0 votes
1 answer
18 views

Trying to do pset 2, but it doesn't even accept my input. What am I doing wrong?

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <math.h> int check(int c, string key); int main(int argc, string argv[]) { int ...
Lakshya Dugar's user avatar
0 votes
1 answer
51 views

Clang can't find -lcs50.h

I am trying to compile my code and make a clang file but every time I try to do it it tells me that the cs50.h file can't be found and I don't know what I can do to fix it. Please help me. I have ...
ecco's user avatar
  • 3
0 votes
0 answers
18 views

Program just exits instead of printing errors

#include <stdio.h> #include <ctype.h> #include <string.h> #include <stdbool.h> #include <cs50.h> int checkerrors(int argc, string argv[]); ...
user avatar
0 votes
0 answers
28 views

isalpha() returns non-zero integer with non-alphabetic character

#include <stdio.h> #include <ctype.h> int main(void) { char c = '+'; int example = isalpha(c); printf("%i\n", example); } It should return 0 but it gives me random ...
user avatar
0 votes
1 answer
70 views

PS2 - substitution

thanks for helping me out :) When I am running my code I get a weird output, an intractable char that is being added randomly to my output. The weird thing is that that the char that is being added is ...
Dan Konstantinovsky's user avatar
0 votes
1 answer
40 views

pset2 making a whole string uppercase for use in substitution.c

I am trying to use the following helper function inside my substitution.c script: string upper(string key) { int n = strlen(key); char key_upper[n]; for (int i = 0; i < n; i++) { ...
invader.zimm's user avatar
0 votes
2 answers
193 views

pset 2 - Substitution - "output not valid ASCII text" error

My substitution cipher is producing the correct output on my terminal when I run the same checks. I have reviewed other responses to similar issues but wasn't able to figure out how to find my error. ...
David's user avatar
  • 11
0 votes
1 answer
303 views

Segmentation fault in Substitution - Problem Set 2

I have finally finished writing my code for the Substitution question in Problem Set 2, but Check50 tells me that my code has a segmentation fault when there is a lack of key. My code is as follows: #...
Ethan Mark's user avatar
0 votes
3 answers
642 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 ...
Ethan Mark's user avatar
0 votes
1 answer
175 views

pset2 substitution

I was trying to do substitiution on two loops but i had some issues. i found onle loop solution here https://stackoverflow.com/questions/61767483/free-invalid-pointer-aborted-core-dumped-cs50 but now ...
Adr's user avatar
  • 1
0 votes
2 answers
199 views

pset2 substitution - isalpha doesn't seem to recognize letters

I'm relatively inexperienced at programming, but I thought I understood how to use command-line prompts well enough to try the substitution problem. I'm having an issue with isalpha that I don't ...
dubflicker's user avatar