Questions tagged [pset2-substitution]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
17 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 ...
0
votes
1answer
34 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 <...
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
50 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 ...
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
22 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 ...
0
votes
1answer
26 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 ...
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
34 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 &...
0
votes
1answer
30 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
0answers
17 views

I am getting 2 following errors on using check50 on my code. Can anyone help?

:( encrypts "This is CS50" as "Cbah ah KH50" using yukfrnlbavmwzteogxhcipjsqd as key output not valid ASCII text :( encrypts "This is CS50" as "Cbah ah KH50" ...
0
votes
1answer
24 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 ...
0
votes
1answer
22 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 "...
0
votes
1answer
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 ...
0
votes
1answer
31 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 ...
0
votes
0answers
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[]); ...
0
votes
0answers
27 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 ...
0
votes
1answer
36 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 ...
0
votes
1answer
23 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++) { ...
0
votes
2answers
85 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. ...
0
votes
1answer
211 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: #...
0
votes
3answers
279 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
147 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 ...
0
votes
2answers
110 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 ...
0
votes
1answer
61 views

Pset2 - Substitution: Output seemed correct, failed on some check50

Thanks in advance for your help. After completing Substitution, I ran check50 in terminal and was surprised to see that I had failed 4 of the checks. After debugging I located the source of the error. ...
0
votes
1answer
49 views

Why do i get these errors? i am new to programming so please be easy on me. The errors are in the body

#include<stdio.h> #include<cs50.h> #include<string.h> #include<ctype.h> bool check_validity_key(string s); int main(int argc, string argv[]) { if (!check_validity_key(argv[...
0
votes
1answer
96 views

PSET 2 Substitution

My question is about a cs50 PSET. The goal is to create some sort of encryption program. From command line arguments there is a key inputted and every key letter should be replaced with the alphabet ...
0
votes
2answers
314 views

PS2 substitution

I am trying to check that the substitution key contains all the alphabets but am getting error: expression result unused for this line of code: s, l ++; Can anyone help, this is my code as of now: ...
0
votes
1answer
2k views

Pset 2 - Substitution

I hope you are all well. Just had a quick question about CS50 Pset2's substituion problem. Please see my code below. #include <stdio.h> #include <cs50.h> #include <string.h> #...
0
votes
2answers
935 views

“Output not valid ASCII text” error with Substitution pset

i'm having these errors when i check my code. This is it: #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> int main(int argv, string argc[]) { ...